On Thu, 11 Feb 2016 at 00:23 Georg Brandl
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: $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, 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 = 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
# making the literal suffix stand out more imag = 1.247812376e-15_j
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.