New submission from Ben Finney:
The language reference carves out a special case for decimal zero literals:
they may have leading “0” digits. Non-zero decimal literals may not. This is
apparently deliberate:
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.
reference/lexical_analysis.html#integer-literals
But the expressed rationale (“for disambiguation with C-style octal literals”)
does not explain making decimal zero special compared with non-zero.
Is there a good reason for this inconsistency::
0000 # valid syntax for zero literal
0003 # SyntaxError
0123 # SyntaxError
To my reading, they should all cause SyntaxError. What is the rationale for the
special case of the first one?
----------
components: Interpreter Core
messages: 261227
nosy: bignose
priority: normal
severity: normal
status: open
title: Leading “0” allowed, only for decimal zero
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26490>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com