[Python-Dev] PEP 515: Underscores in Numeric Literals (original) (raw)
Brett Cannon brett at python.org
Thu Feb 11 13:05:44 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 Thu, 11 Feb 2016 at 00:23 Georg Brandl <g.brandl at gmx.net> 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. --------------------------------------------------------------------------- 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, floating-point and complex 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 # making the literal suffix stand out more imag = 1.247812376e-15j
Specification ============= The current proposal is to allow one or more consecutive underscores following digits and base specifiers in numeric literals.
+1 from me. Nice and simple! And we can always update PEP 8 do disallow any usage that we deem ugly. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160211/08d4f0f6/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 ]