[Python-ideas] Improve readability of long numeric literals
Dan Sommers
dan at tombstonezero.net
Tue Feb 9 23:30:11 EST 2016
On Wed, 10 Feb 2016 11:50:41 +1100, Steven D'Aprano wrote:
> Floats are more complex:
>
> 123_456.000_001e-23
Floats are less complex. Complexes are more complex:
22j
123_456.000_001e-23j
:-)
> looks okay to me, but what about this?
>
> 123_456_._000_001_e_-_23
Agreed: that is no longer more readable.
All I can think of for a use case for leading underscores would be to
line up values of different lengths:
x4 = __4
x5 = _33
x6 = __4
x7 = 220
milli = 1e__-3
micro = 1e__-6
nano = 1e__-9
pico = 1e_-12
femto = 1e_-15
But PEP 8 already suggests otherwise:
milli = 1e-3
micro = 1e-6
nano = 1e-9
pico = 1e-12
femto = 1e-15
More information about the Python-ideas
mailing list