"Don't rebind built-in names*" - it confuses readers

Chris Angelico rosuav at gmail.com
Mon Jun 10 23:57:04 EDT 2013


On Tue, Jun 11, 2013 at 1:02 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Apart from Erlang, got any other examples? Because it seems to me that in
> languages with nested scopes or namespaces, shadowing higher levels is
> exactly the right thing to do. Certainly it would be a PITA, and defeat
> the purpose of having nested scopes, if inner names had to be globally
> unique.

I agree, and it's one of the reasons that I like the explicitness of
C's variable declarations. Sure, Python makes it easier to write code;
but it's easier to figure out what's a global and what's not when
locals are all declared. (Yes, it's not that hard for a human to
recognize when a name is being rebound as opposed to merely used, but
it's extra work for a lexer/syntax highlighter.)

ChrisA



More information about the Python-list mailing list