When I type small integers with a 0 in front into python, they give weird results. Why is this?
>>> 011
9
>>> 0100
64
>>> 027
23
<
The latest Python specification for number literals is in PEP-3127 "Integer Literal Support and Syntax"
The syntax for 011 has been removed in Python 3.0. The syntax for 0o11 has been added in Python 2.6 and it is the only one supported after Python 3.0. There is no __future__
import in Python 2 that would disallow or atleast warn on number literals with leading zeros, so developers have to know what 011 means and that it should be avoided (and that it can actually be avoided).