by bubblesocks · 9y ago · 0 comments
>>> "%(foo)s" % {"foo": "bar"}
'bar' $ printf '%2$s %2$s %1$s\n' aaa bbb
bbb bbb aaa >>> 'hello, %s %s' % tuple(reversed(['smith', 'bob']))
'hello, bob smith'
I think it's more readable if you abstract that bit into a lambda function: >>> rev_args = lambda *args: tuple(reversed(args))
>>> 'hello, %s %s' % rev_args('smith', 'bob')
'hello, bob smith'