[issue14694] Option to show leading zeros for bin/hex/oct
Eric V. Smith
report at bugs.python.org
Tue May 1 13:09:06 CEST 2012
Eric V. Smith <eric at trueblade.com> added the comment:
I agree with Mark.
This can also be done slightly more efficiently with plain format():
>>> format(324, "016b")
'0000000101000100'
>>> format(324, "016o")
'0000000000000504'
>>> format(324, "016x")
'0000000000000144'
And with either format() or str.format(), you can add the appropriate prefix:
>>> format(324, "#016b")
'0b00000101000100'
>>> format(324, "#016o")
'0o00000000000504'
>>> format(324, "#016x")
'0x00000000000144'
I don't see ever adding all of the possible options to bin(), etc.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14694>
_______________________________________
More information about the Python-bugs-list
mailing list