On 2/6/20 7:03 AM, Jonathan Fine wrote:
SUMMARY
=========

It was once a good idea, for Python 3 to forbid leading zeroes in integer literals. Since then circumstances have changed. Perhaps it's now, or soon will be, a good time to permit this.

A SURPRISE
==========

I was surprised by:
>>> 0
0
>>> 00
0
>>> 000
0
>>> 001
SyntaxError: invalid token

Just thinking a bit, it should be safe to relax the prohibition for numbers with only 1 significant digit. 02 is ok, 020 is not, since numbers with 1 significant digit can't be misinterpreted.

As to when it would be safe to totally remove that protection, Python 2.x isn't dead yet, and really won't be for awhile. It may be that the python developer have declared that support for it from them is over (though there still is that last release in April still to come), but it will still be alive, maybe on life support, while the various Long Term Support distributions maintain it. That won't end till some time next year by my understanding. And then you have people who will still use the unsupported 2.7 while they work on switching over and trying to figure out how to make their ancient code work on these new systems.

This doesn't mean that Python 3.x needs to bend over backwards to cater to 2.7 users, but thought should be made that there are, and will be for a while, People used to Python 2.x

In this particular case, since many other langagues and some operating systems use as simple leading zero to indicate octal, it may make sense to just keep the ambiguous numbers invalid forever. If we admit that the reasoning is ambiguity, then allowing the single digit numbers could make sense even if it does mean that writing the rule as a grammar is complicated.

--
Richard Damon
_______________________________________________
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/465IXJDGDM5KKC3RAZBY4WT5BRYWUDQL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to