This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients eajames, eric.smith, mark.dickinson, r.david.murray
Date 2016-09-02.17:17:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1472836630.7.0.826332679913.issue27934@psf.upfronthosting.co.za>
In-reply-to
Content
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'
History
Date User Action Args
2016-09-02 17:17:10mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, r.david.murray, eajames
2016-09-02 17:17:10mark.dickinsonsetmessageid: <1472836630.7.0.826332679913.issue27934@psf.upfronthosting.co.za>
2016-09-02 17:17:10mark.dickinsonlinkissue27934 messages
2016-09-02 17:17:10mark.dickinsoncreate