[Tutor] Why does 01 give a syntax error, but 00 (or 00...0) does not?
Ben Finney
ben+python at benfinney.id.au
Sat Mar 5 19:42:08 EST 2016
Ben Finney <ben+python at benfinney.id.au> writes:
> Hmm. That is a confusing inconsistency, I agree. It is deliberate, and
> explicitly documented:
>
> Note that leading zeros in a non-zero decimal number are not
> allowed. This is for disambiguation with C-style octal literals,
> which Python used before version 3.0.
>
> <URL:https://docs.python.org/3/reference/lexical_analysis.html#integer-literals>
>
> which does not explain why “non-zero decimal number” was chosen, rather
> than simply any decimal number.
I have reported <URL:https://bugs.python.org/issue26490> to try to
resolve this ambiguity.
--
\ “They who can give up essential liberty to obtain a little |
`\ temporary safety, deserve neither liberty nor safety.” |
_o__) —Benjamin Franklin, 1775-02-17 |
Ben Finney
More information about the Tutor
mailing list