This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author endolith
Recipients endolith
Date 2012-04-29.16:12:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1335715935.12.0.0678651117983.issue14694@psf.upfronthosting.co.za>
In-reply-to
Content
Suggestion: Add an option to bin/hex/oct functions to format binary output with a minimum fixed width, including leading zeros.  Also might be useful for hex and oct.

Currently, bin(18) produces '0b10010'

with this change, something like bin(18, foo=8) would produce '0b00010010'


Examples of people wanting this:

http://stackoverflow.com/questions/3258330/converting-from-hex-to-binary-without-losing-leading-0s-python

http://stackoverflow.com/questions/1002116/can-bin-be-overloaded-like-oct-and-hex-in-python-2-6

http://stackoverflow.com/a/1425558/125507

https://www.linuxquestions.org/questions/programming-9/in-python-printing-leading-zero-for-hex-numbers-0-through-f-719426/
History
Date User Action Args
2012-04-29 16:12:15endolithsetrecipients: + endolith
2012-04-29 16:12:15endolithsetmessageid: <1335715935.12.0.0678651117983.issue14694@psf.upfronthosting.co.za>
2012-04-29 16:12:14endolithlinkissue14694 messages
2012-04-29 16:12:14endolithcreate