Why no warnings when re-assigning builtin names?
Tim Chase
python.list at tim.thechases.com
Tue Aug 16 14:34:53 EDT 2011
On 08/16/2011 12:11 PM, Seebs wrote:
> Under which circumstance will you have more problems?
>
> 1. There is not a single shadowed built-in in the entire project.
> 2. There are dozens of shadowed built-ins based on when the original
> programmer felt there wasn't going to be a need for a given built-in
> feature, or possibly just didn't know about it.
In practice, I've never hit such a snag. For #2, the only way it
would impact me is if I did the ill-advised
from shadowy import *
which might tromp on things I care about. Otherwise, I'd just do
something like
from shadowy import list as shadowy_list, id as shadowy_id
If I'm altering another person's ill-created module, I might
consider doing a search for builtins and then just simply
patching the module so that it renamed all the shadowing usages.
Unless the author was being particularly obscure (using scope
to impact where a builtin meant the builtin, and other scopes to
shadow the builtins), most authors are pretty consistent in their
shadowing (usually ignorant of the fact they're shadowing the
builtin) which makes the search-n-replace an easy tweak.
-tkc
More information about the Python-list
mailing list