[issue33304] Syntax Error on leading 0 in integer tokens

Steven D'Aprano report at bugs.python.org
Tue Apr 17 21:25:39 EDT 2018


Steven D'Aprano <steve+python at pearwood.info> added the comment:

This is not a bug, it is intentional.

In Python 2, numbers with a leading zero are interpreted as octal, leading to surprising results:

py> 015
13

In Python 3, we use 0o15 to get octal, and 015 becomes a syntax error.

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33304>
_______________________________________


More information about the Python-bugs-list mailing list