[issue39225] Python should warn when a global/local has the same name as a builtin

2020-01-05 Thread Reuven Lerner


New submission from Reuven Lerner :

Newcomers to Python are often frustrated and surprised when they define 
variables such as "sum" and "list", only to discover that they've masked access 
builtins of the same name.

External code checkers do help, but those don't work in Jupyter or other 
non-IDE environments.

It would be nice if defining a global/local with the same name as a builtin 
would generate a warning.  For example:

list = [10, 20, 30]
RedefinedBuiltinWarning: "list" is a builtin, and should normally not be 
redefined. 

I'm sure that the wording could use a lot of work, but something like this 
would do wonders to help newbies, who encounter this all the time. Experienced 
developers are surprised that these terms aren't reserved words.

--
components: Interpreter Core
messages: 359384
nosy: reuven
priority: normal
severity: normal
status: open
title: Python should warn when a global/local has the same name as a builtin

___
Python tracker 
<https://bugs.python.org/issue39225>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42469] Space in re's {min, max} should raise an error, rather than fail silently

2020-11-25 Thread Reuven Lerner


New submission from Reuven Lerner :

I just discovered that having whitespace inside of {min,max} causes the regexp 
to report no matches, rather than an error:

>>> import re
>>> s = 'abbccce'
>>> re.findall('d{1, 4}', s)
[]
>>> re.findall('d{1,4}', s)
['']

Ruby and JavaScript have the same behavior, so maybe this is standard in some 
way. But I find it hard to believe that it's desirable. (My post on Twitter 
about this confirmed that a whole lot of people were bitten by this bug in the 
past.)

BSD grep, GNU grep, and GNU Emacs all raise an error upon encountering this 
whitespace, which strikes me as less surprising and more useful behavior.

--
components: Regular Expressions
messages: 381879
nosy: ezio.melotti, mrabarnett, reuven
priority: normal
severity: normal
status: open
title: Space in re's {min,max} should raise an error, rather than fail silently
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue42469>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com