(Mar-22-2023, 10:36 PM)tester_V Wrote: 1 and 01 are the same numbers.
You might hope that (and generally for 01, you're correct). But in some contexts a leading zero is significant and changes the meaning.
In python2, a leading zero was an indication for an octal literal.
Python 2.7.15 (default, Jan 24 2020, 13:07:12)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 21
21
>>> 021
17
This can be unexpected. So this format is not used in python3. Now an octal literal requires the explicit
0o
prefix. Meanwhile a plain leading zero was made illegal so there's no chance old code that expected it to be an octal will run incorrectly.