print format for binary representation

Rim rimbalaya at
Tue Jan 27 16:00:23 CET 2004


>>> print '%x' % 54
>>> print '%b' % 54
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: unsupported format character 'b' (0x62) at index 1

No formating string for binary? There %x for hex. Would %b make sense
for bin? Is this worth a PEP?

How do I get 00110110 printed instead of the traceback?


More information about the Python-list mailing list