Why no warnings when re-assigning builtin names?

Seebs usenet-nospam at seebs.net
Tue Aug 16 19:11:38 CEST 2011


On 2011-08-16, Ethan Furman <ethan at stoneleaf.us> wrote:
> What makes you think it's unintentional?

Programming experience.

People *often* do things unintentionally.

> Seems to me the real issue is somebody using a builtin, such as str or 
> int, and that they somehow manage to do this without realizing, "wait a 
> sec', that's one of my variables!"  I don't see that as a problem that 
> Python needs to solve.

I think the word "my" prejudices the case.

Imagine stepping into a large project that uses multiple frameworks and
class libraries and so on.  You know Python but you're new to the project.

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.

Also, how easy or hard do you think it will be to debug those problems?
What's your first response going to be if, on a screen which doesn't
contain the word file at all, you try to use the file built-in and you
get some cryptic error?  Are you going to know to go looking for the
shadow right away?

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.



More information about the Python-list mailing list