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

Reuven Lerner report at bugs.python.org
Sun Jan 5 17:18:09 EST 2020


New submission from Reuven Lerner <reuven at lerner.co.il>:

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 <report at bugs.python.org>
<https://bugs.python.org/issue39225>
_______________________________________


More information about the New-bugs-announce mailing list