[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-15 Thread Damian Shaw
This isn't a "professional" or probably even "valid" use case for Python but one area this behavior is heavily used is code golf. For those not familiar with code golf is a type of puzzle where the objective is to complete a set of requirements in the least number of source code characters as possi

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-14 Thread Victor Stinner
Also, would it be possible to enhance to tokenizer to report a SyntaxWarning, rather than a SyntaxError? Victor ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailm

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-13 Thread David Mertz
I feel like all of these examples, if found in the wild, are far more likely to be uncaught bugs than programmer intent. Being strict about spaces (or parents, brackets, etc. in other contexts) around numbers is much more straightforward than a number of edge cases where is not obvious what will ha

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-13 Thread Victor Stinner
It would be useful to first estimate how many projects would be broken by such incompatible change (stricter syntax). Inada-san wrote https://github.com/methane/notes/blob/master/2020/wchar-cache/download_sdist.py to download source files using https://hugovk.github.io/top-pypi-packages/ API (top

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-13 Thread Greg Ewing
On 14/04/21 8:54 am, Guido van Rossum wrote: On Tue, Apr 13, 2021 at 12:55 PM Serhiy Storchaka >  >>> [0x1for x in (1,2)] I would totally make that a SyntaxError, and backwards compatibility be damned. Indeed. Python is not Fotran! -- Greg __

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-13 Thread Barry Warsaw
On Apr 13, 2021, at 12:52, Serhiy Storchaka wrote: > > New example was found recently (see https://bugs.python.org/issue43833). > [0x1for x in (1,2)] > [31] > > It is parsed as [0x1f or x in (1,2)] instead of [0x1 for x in (1,2)]. That’s a wonderfully terrible example! Who’s maintaining

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-13 Thread Guido van Rossum
On Tue, Apr 13, 2021 at 12:55 PM Serhiy Storchaka wrote: > 26.04.18 21:37, Serhiy Storchaka пише: > > In Python 2.5 `0or[]` was accepted by the Python parser. It became an > > error in 2.6 because "0o" became recognizing as an incomplete octal > > number. `1or[]` still is accepted. > > > > On oth

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-13 Thread Serhiy Storchaka
26.04.18 21:37, Serhiy Storchaka пише: > In Python 2.5 `0or[]` was accepted by the Python parser. It became an > error in 2.6 because "0o" became recognizing as an incomplete octal > number. `1or[]` still is accepted. > > On other hand, `1if 2else 3` is accepted despites the fact that "2e" can > b