[New-bugs-announce] [issue14694] Option to show leading zeros for bin/hex/oct
endolith
report at bugs.python.org
Sun Apr 29 18:12:15 CEST 2012
New submission from endolith <endolith at gmail.com>:
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/
----------
components: Interpreter Core
messages: 159623
nosy: endolith
priority: normal
severity: normal
status: open
title: Option to show leading zeros for bin/hex/oct
type: enhancement
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14694>
_______________________________________
More information about the New-bugs-announce
mailing list