On 2018-12-08 01:17, jf...@ms4.hinet.net wrote:
00
0
03
File "<stdin>", line 1
03
^
SyntaxError: invalid token
Any particular reason?
Before Python 3, a leading 0 in an integer literal would indicate an
octal (base 8) number.
In Python 2.7:
>>> 010
8
That notation was borrowed from C.
The hexadecimal (base 16) notation of a leading 0x was also borrowed
from C (it was a later introduction to the language).
Python also has the binary (base 2) notation of a leading 0b.
For Python 3, it was felt that it would be clearer to have an octal
notation that didn't use just a leading 0, so it was changed to a
leading 0o.
The old form is now invalid in order to reduce the chance of bugs.
If you're coming from Python 2, you might expect that 010 is still
octal, and if you're not familiar with that notation, you might expect
that it's decimal.
--
https://mail.python.org/mailman/listinfo/python-list