2

within python runtime environment, try the following:

>> *type(01207)*

you'll get:

<type 'int'>

then try with:

>> *type(01208)*

you will get:

File "<stdin>", line 1
type(01208)
         ^
Brian Rogers
  • 125,747
  • 31
  • 299
  • 300
Geoffrey
  • 75
  • 5
  • 1
    Same way that `type(08)` or `08` is invalid. – dawg May 28 '13 at 02:31
  • 3
    Definitely a bug. I'm afraid that it's in _your_ code, though. – jscs May 28 '13 at 02:31
  • +1 for considering that it might have special meaning (The same meaning applies to many other languages). It is [in the docs](http://docs.python.org/2/reference/lexical_analysis.html#integer-and-long-integer-literals) – John La Rooy May 28 '13 at 02:42
  • Any *numeric* value that starts with 0 is an octal (base 8) number, and there is no 8 in base 8. – Mp0int May 28 '13 at 07:37

1 Answers1

7

No it isn't a bug, by prefixing the number with 0 you are using octal and 8 is not a valid digit in base 8.

>>> 07
7
>>> 08
SyntaxError: invalid token
>>> 010
8

Python 3 uses a 0o prefix (only - you can do both in 2.7) instead to remove this ambiguity.

jamylak
  • 128,818
  • 30
  • 231
  • 230