[New-bugs-announce] [issue5749] Allow bin() to have an optional "Total Bits" argument.

MechPaul report at bugs.python.org
Tue Apr 14 03:01:19 CEST 2009

New submission from MechPaul <mechpaul at gmail.com>:

As it stands right now, bin() only shows the minimum number of bits to
display the number, however I think having a "Total Bits" argument would
be very, very useful for bin().

bin(value, [Total bits to display])

"Total bits to display" is an integer.

Here's how it should work:

>>> bin(0x7F)
>>> #Note, there are seven 1's there to represent the value 127
>>> bin(0x7F, 8)
>>> #Now there are eight bits displayed.
>>> bin(0xFF, 16)
>>> #This makes it a lot easier to read and compare binary numbers!

components: Interpreter Core
messages: 85956
nosy: MechPaul
severity: normal
status: open
title: Allow bin() to have an optional "Total Bits" argument.
type: feature request
versions: Python 3.1

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list