06.02.20 14:03, Jonathan Fine пише:
>>> 001
SyntaxError: invalid token
The error message was improved in the latest Python:
001
File "<stdin>", line 1
SyntaxError: leading zeros in decimal integer literals are not
permitted; use an 0o prefix for octal integers
1. It was good to remove from Python3 the octal trap for 010. (In the
beginning, most Python users already knew C. I doubt that's true now.
And explicit is better than implicit.)
C is still in use. As well as other programming languages which use the
C format for octals.
3. Python2 is now obsolete. Perhaps now, or sometime in the next year or
two, it makes sense to enable leading zeros in integer literals.
It is obsolete, but is still in use, and will be for many years (maybe
tens of years). There is no official release of CPython 2.7 planned
after April of 2020, but other implementations (PyPy, Jython) can
continue to release new versions. Some companieas will provide
distributions of CPython 2.7 for years (maybe with their own patches).
4. This would allow us to remove the newby trap, by providing:
>>> datetime.date(2020, 02, 06)
datetime.date(2020, 02, 06)
It is not a trap. It is just an error, and the compiler immediately give
you a clue how to to fix it (remove leading 0s if you meant decimals,
and use the 0o prefix if you meant octals).
The trap is using 0776 for octal 0o776 and get a decimal 776 instead.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/7MR2LGOLYWONHGROMVUY6C7QJRRHTEZY/
Code of Conduct: http://python.org/psf/codeofconduct/