Why no warnings when re-assigning builtin names?

Chris Angelico rosuav at gmail.com
Wed Aug 17 03:34:22 EDT 2011

On Wed, Aug 17, 2011 at 1:58 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
>> My thoughts would be:
>> 1.  It's hard to avoid shadowing anything unless you know the entire
>> language and never forget things.
> Define the "entire language". Does that include the names of all the
> plethora of exceptions? How about the standard library?

The shadowing issue applies to the standard library as well as the
builtins, so yes; to avoid shadowing *anything*, you would have to
know the entire language. I posit that this is a practical
impossibility, and that unexpected shadowing will always be possible
(and won't always be prevented by syntax highlighting). Some day
you'll discover that you can't use module X because you have a
function called X, and you'll have to rename.


More information about the Python-list mailing list