[Python-Dev] Proposal: make float.str identical to float__repr__ in Python 3.2 (original) (raw)
Mark Dickinson dickinsm at gmail.com
Thu Jul 29 20:47:37 CEST 2010
- Previous message: [Python-Dev] unexpected import behaviour
- Next message: [Python-Dev] Proposal: make float.__str__ identical to float__repr__ in Python 3.2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Now that we've got the short float repr in Python, there's less value in having float.str truncate to 12 significant digits (as it currently does). For Python 3.2, I propose making float.str use the same algorithm as float.repr for its output (and similarly for complex).
Apart from simplifying the internals a little bit, one nice feature of this change is that it removes the differences in formatting between printing a float and printing a container of floats:
l = [1/3, 1/5, 1/7] print(l) [0.3333333333333333, 0.2, 0.14285714285714285] print(l[0], l[1], l[2]) 0.333333333333 0.2 0.142857142857
Any thoughts or comments on this?
There's a working patch at http://bugs.python.org/issue9337
Mark
- Previous message: [Python-Dev] unexpected import behaviour
- Next message: [Python-Dev] Proposal: make float.__str__ identical to float__repr__ in Python 3.2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]