[issue3008] Let bin() show floats
Alexander Belopolsky
report at bugs.python.org
Fri May 30 19:35:31 CEST 2008
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
While writing my previous comments I did not realize that '%x' % accepts
floats:
>>> "%x" % 3.1415
'3'
Float support has been even improved somewhat since 2.5:
Python 2.5 (r25:51908, Nov 24 2006, 11:03:50)
>>> '%x' % 1e10
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int argument required
The new stile formatting, however does not allow floats with either :x
or :b formats:
>>> "{0:x}".format(1.)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown conversion type x
>>> "{0:b}".format(1.)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown conversion type b
I don't think anything needs to be done about it given that % formatting
is being deprecated while new style format is doing the right thing IMO.
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3008>
_______________________________________
More information about the Python-bugs-list
mailing list