Python cannot handle numbers string starting with 0. Why?

My guess is that since 012 is no longer an octal literal constant in python3.x, they disallowed the 012 syntax to avoid strange backward compatibility bugs. Consider your python2.x script which using octal literal constants:

a = 012 + 013

Then you port it to python 3 and it still works — It just gives you a = 25 instead of a = 21 as you expected previously (decimal). Have fun tracking down that bug.

Leave a Comment