[Python-Dev] PEP 515: Underscores in Numeric Literals (original) (raw)
Glenn Linderman v+python at g.nevcal.com
Wed Feb 10 17:42:52 EST 2016
- Previous message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Next message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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: RevisionRevisionRevision Last-Modified: DateDateDate 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 = 10000000.0 # grouping hexadecimal addresses by words addr = 0xDEADBEEF # grouping bits into bytes in a binary literal flags = 0b0011111101001110
+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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160210/570f311c/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Next message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]