Why gives "k = 09" a syntax error ?

Terry Reedy tjreedy at udel.edu
Thu Oct 30 00:03:31 CET 2008


Mensanator wrote:
> On Oct 29, 4:25 pm, Terry Reedy <tjre... at udel.edu> wrote:
>> Stef Mientki wrote:
>>> hello,
>>> Why gives "k = 09"  a syntax error ?
>> You have gotten the 2.x answer.  In 3.0, 0b,0o,0x prefixes are valid and
>> required for binary, octal, and hexadecimal literals.  0digits is invalid.

except 00, 000, etc.


> Is it documented? :-)

Very clearly.

Integer literals
Integer literals are described by the following lexical definitions:

integer        ::=  decimalinteger | octinteger | hexinteger | bininteger
decimalinteger ::=  nonzerodigit digit* | "0"+
nonzerodigit   ::=  "1"..."9"
digit          ::=  "0"..."9"
octinteger     ::=  "0" ("o" | "O") octdigit+
hexinteger     ::=  "0" ("x" | "X") hexdigit+
bininteger     ::=  "0" ("b" | "B") bindigit+
octdigit       ::=  "0"..."7"
hexdigit       ::=  digit | "a"..."f" | "A"..."F"
bindigit       ::=  "0" | "1"




More information about the Python-list mailing list