Why no warnings when re-assigning builtin names?

Benjamin Kaplan benjamin.kaplan at case.edu
Tue Aug 16 00:52:42 CEST 2011


On Aug 15, 2011 5:56 PM, "Gerrat Rickert" <grickert at coldstorage.com> wrote:
>
> With surprising regularity, I see program postings (eg. on StackOverflow)
from inexperienced Python users  accidentally re-assigning built-in names.
>
>
>
> For example, they’ll innocently call some variable, “list”, and assign a
list of items to it.
>
> ...and if they’re _unlucky_ enough, their program may actually work
(encouraging them to re-use this name in other programs).
>
>
>
> If they try to use an actual keyword, both the interpreter and compiler
are helpful enough to give them a syntax error, but I think the builtins
should be “pseudo-reserved”, and a user should explicitly have to do
something *extra* ...
>
>
> What sayest the Python community about having an explicit warning against
such un-pythonic behaviour (re-assigning builtin names)?
>

One of Python's greatest strength's in my opinion is that it strives for
consistency. As much as possible, Python avoids differentiating between
built-in objects (types or otherwise) and user-defined objects. I think it
should stay that way. There are tools that can detect these errors and their
use should be encouraged, but the Python interpreter shouldn't single out
variables which are types that happen to be built-in from any other variable
or any other type.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110815/f61408c3/attachment.html>


More information about the Python-list mailing list