Why no warnings when re-assigning builtin names?

Ethan Furman ethan at stoneleaf.us
Mon Aug 15 19:12:07 EDT 2011


Seebs wrote:
> On 2011-08-15, Ethan Furman <ethan at stoneleaf.us> wrote:
>> Gerrat Rickert wrote:
>>> What sayest the Python community about having an explicit warning 
>>> against such un-pythonic behaviour (re-assigning builtin names)?
> 
>> What makes you think this behavior is unpythonic?  Python is not about 
>> hand-holding.
> 
> It seems like something which is sufficiently likely to be a mistake might
> deserve a warning -- especially since, so far as I can tell, there's never
> going to be a program which can't easily be written to avoid the problematic
> behavior.

"sufficiently likely" depends entirely on who is doing the coding.  I 
use `open()` for opening my files, and so regularly use `file` as a 
name.  It can also be very handy to mask a built-in when doing something 
even more fun and entertaining and I, for one, have zero desire to have 
Python start warning me about perfectly legitimate code.

Programmers need to learn whichever language they are choosing to code 
in, and if extra help is needed beyond whatever is basic for that 
language, find (or write! ;) the third-party tool to help out.  There 
are at least two linters for Python, and multiple IDEs that can help 
with these, and other, problems.  (I don't much care for IDEs, but I am 
thinking of starting to use a linter, myself.)

~Ethan~



More information about the Python-list mailing list