Clarify what the underscores actually mean.
This commit is contained in:
parent
eb4e4467a9
commit
2c56f53fcb
14
pep-0515.txt
14
pep-0515.txt
|
@ -13,8 +13,9 @@ Post-History: 10-Feb-2016, 11-Feb-2016
|
|||
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 PEP proposes to extend Python's syntax so that underscores can be used as
|
||||
visual separators for digit grouping purposes 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
|
||||
|
@ -39,7 +40,8 @@ Specification
|
|||
=============
|
||||
|
||||
The current proposal is to allow one or more consecutive underscores following
|
||||
digits and base specifiers in numeric literals.
|
||||
digits and base specifiers in numeric literals. The underscores have no
|
||||
semantic meaning, and literals are parsed as if the underscores were absent.
|
||||
|
||||
The production list for integer literals would therefore look like this::
|
||||
|
||||
|
@ -47,9 +49,9 @@ The production list for integer literals would therefore look like this::
|
|||
decimalinteger: nonzerodigit (digit | "_")* | "0" ("0" | "_")*
|
||||
nonzerodigit: "1"..."9"
|
||||
digit: "0"..."9"
|
||||
octinteger: "0" ("o" | "O") (octdigit | "_")*
|
||||
hexinteger: "0" ("x" | "X") (hexdigit | "_")*
|
||||
bininteger: "0" ("b" | "B") (bindigit | "_")*
|
||||
octinteger: "0" ("o" | "O") "_"* octdigit (octdigit | "_")*
|
||||
hexinteger: "0" ("x" | "X") "_"* hexdigit (hexdigit | "_")*
|
||||
bininteger: "0" ("b" | "B") "_"* bindigit (bindigit | "_")*
|
||||
octdigit: "0"..."7"
|
||||
hexdigit: digit | "a"..."f" | "A"..."F"
|
||||
bindigit: "0" | "1"
|
||||
|
|
Loading…
Reference in New Issue