March 10, 2016
5:47 p.m.
Serhiy Storchaka added the comment:
That's why I ran the micro-benchmark and, in fact, I was expecting %-interpolation to be faster exactly because it is less flexible.
Actually %-interpolation is more flexible.
'%x' % 123 '7b' '%0X' % 123 '7B' '%#x' % 123 '0x7b' '%04x' % 123 '007b'
If document alternatives for hex(), we should also document formatting alternatives for bin(), oct(), repr(), ascii(), str(), chr(), str.ljust(), str.rjust(), str.center(), str.zfill(). ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26506> _______________________________________