On 02/10/2016 11:42 PM, Glenn Linderman wrote:
> On 2/10/2016 2:20 PM, Georg Brandl wrote:
>> This came up in python-ideas, and has met mostly positive comments,
>> although the exact syntax rules are up for discussion.
>>
>> cheers,
>> Georg
>>
>> --------------------------------------------------------------------------------
>>
>> PEP: 515
>> Title: Underscores in Numeric Literals
>> Version: $Revision$
>> Last-Modified: $Date$
>> Author: Georg Brandl
>> Status: Draft
>> Type: Standards Track
>> Content-Type: text/x-rst
>> Created: 10-Feb-2016
>> Python-Version: 3.6
>>
>> Abstract and Rationale
>> ======================
>>
>> This PEP proposes to extend Python's syntax so that underscores can be used 
>> in
>> integral and floating-point number literals.
>>
>> This is a common feature of other modern languages, and can aid readability 
>> of
>> long literals, or literals whose value should clearly separate into parts, 
>> such
>> as bytes or words in hexadecimal notation.
>>
>> 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
>>     flags = 0b_0011_1111_0100_1110
> 
> +1
> 
> You don't mention potential restrictions that decimal numbers should permit 
> them
> only every three places, or hex ones only every 2 or 4, and your binary 
> example
> mentions grouping into bytes, but actually groups into nybbles.
> 
> But such restrictions would be annoying: if it is useful to the coder to use
> them, that is fine. But different situation may find other placements more
> useful... particularly in binary, as it might want to match widths of various
> bitfields.
> 
> Adding that as a rejected consideration, with justifications, would be 
> helpful.

I added a short paragraph.

Thanks for the feedback,
Georg



_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to