+ 2
Error in python
I think I found and error in the Python language. It fails to parse leading zeros in integers. Print(0123) will caused the error. Mathematically 0123 is still 123, I know that's unusual but it still valid. https://code.sololearn.com/c9enYpb17tjz/?ref=app
3 Antworten
+ 4
perl prints 83 for print(0123), it thinks 0123 is octal not an error
+ 4
good question and thanks for the information 💗🙌
+ 3
Python's expecting an integer literal specifier:
https://docs.python.org/3/reference/lexical_analysis.html#integer-literals
0xFF
0b010010
In Python 3, octal literals require an "o":
0o1234
Specifically with respect to integers starting with 0, I understand this syntax error and the "0o..." disambiguation of octal literals (from C-style octals, as used in Python 2) to be intentional.
* edit: It took me a while to find the right docs, Googling for "integer literals" is noisy.