Mark Dickinson added the comment:

Yes. I'm fairly convinced about the bug part; it's the gratuitous breakage part 
that worries me. It wouldn't surprise me at all to find that there's someone 
out there who wants all their numbers to be written out to JSON with exactly 6 
places after the point, and subclasses float just for that purpose. (I'm not 
for a moment suggesting that this is a good idea, but there's a big difference 
between the set of Python code that *should* have been written and the set of 
Python code that *has* been written. :-)

>>> class MyFloat(float):
...     def __repr__(self):
...         return '{:.6f}'.format(self)
... 
>>> import math, json
>>> json.dumps(MyFloat(math.pi))
'3.141593'

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27934>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to