[Python-Dev] PEP 515: Underscores in Numeric Literals

Glenn Linderman v+python at g.nevcal.com
Thu Feb 11 14:04:20 EST 2016


On 2/11/2016 12:22 AM, Georg Brandl wrote:
> Hey all,
>
> based on the feedback so far, I revised the PEP.  There is now
> a much simpler rule for allowed underscores, with no exceptions.
> This made the grammar simpler as well.

+1 overall

> Examples::
>
>      # grouping decimal numbers by thousands
>      amount = 10_000_000.0
>
>      # grouping hexadecimal addresses by words
>      addr = 0xDEAD_BEEF
>
>      # grouping bits into bytes in a binary literal
nybbles, not bytes, is shown... which is more readable, and does group 
into bytes also.
>      flags = 0b_0011_1111_0100_1110

+1 on 0b_ and 0X_ and, especially, 0O_ (but why anyone would use 
uppercase base designators is beyond me, as it is definitely less readable)

>      # making the literal suffix stand out more
>      imag = 1.247812376e-15_j

+1 on _j

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20160211/533488f9/attachment.html>


More information about the Python-Dev mailing list