By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

Re: Why gives "k = 09" a syntax error ?

P: n/a
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.

tjr

Oct 29 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Oct 29, 4:25*pm, Terry Reedy <tjre...@udel.eduwrote:
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.

tjr
Is it documented? :-)
Oct 29 '08 #2

P: n/a
Mensanator wrote:
On Oct 29, 4:25 pm, Terry Reedy <tjre...@udel.eduwrote:
>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.

tjr

Is it documented? :-)
Yes.

http://www.python.org/dev/peps/pep-3127/

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Oct 29 '08 #3

P: n/a
Mensanator wrote:
On Oct 29, 4:25 pm, Terry Reedy <tjre...@udel.eduwrote:
>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"

Oct 29 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.