[Python-ideas] Improve readability of long numeric literals

Guido van Rossum guido at python.org
Tue Feb 9 23:53:16 EST 2016


Let me show you how silly this looked to me...

On Tuesday, February 9, 2016, Dan Sommers <dan at tombstonezero.net
<javascript:_e(%7B%7D,'cvml','dan at tombstonezero.net');>> wrote:

> 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
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido (mobile)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160209/2a91671a/attachment.html>


More information about the Python-ideas mailing list