4 ms·
Reversing the order is not possible, but you can use a dict instead: >>> "%(foo)s" % {"foo": "bar"} 'bar'
by Franciscouzo 10y ago
Reversing the order is not possible, but you can use a dict instead:
>>> "%(foo)s" % {"foo": "bar"}
'bar'
- libeclipse 10y agoHeyyyyyy I did not know that. TIL, thank you.
- dozzie 10y agoFunny. I thought Python implemented all the quirks of the original printf() formatting, including using arguments at specific positions. Apparently it didn't (and arguably it's a good thing). $ printf '%2$s %2$s %1$s\n' aaa bbb bbb bbb aaa