Python handles globals badly.

Chris Angelico rosuav at gmail.com
Tue Dec 2 23:36:48 EST 2014


On Wed, Dec 3, 2014 at 3:17 PM, Skybuck Flying <skybuck2000 at hotmail.com> wrote:
> I hope python one day gets rid of it;
>
> 1. To stop the confusion.
> 2. To stop the doubt.
> 3. To stop the wasted lines.
> 4. To program with more confidence.
> 5. To stop to have to inspect what's going on if one wants to know for sure.
> 6. To stop any weird programming mistakes because a global declaration was
> not used somewhere in a function, it's probably easier to miss, cause in the
> programmers mind he's thinking: "it's global".
>
> Now it's just some
> half-ass-fucked-up-not-really-global-variable-unless-you-specify-it-local-to-be-global-holy-shit-batman-feel-the-brain-pain
> ?!
>

If you want C-like infinitely nested scopes, you basically have to
have declared variables, which Python doesn't want. There are other
languages which are very Python-like but do have declared variables
and infinitely-nested scopes, but I'm not sure I want to deal with
this kind of anger on another mailing list, so I won't name one. Once
again, though, you need to (a) learn the language before getting
irate, and (b) play to its strengths, not its weaknesses. Python's
requirement to declare all globals is a major weakness when you have
hundreds of globals, so don't do that (or don't complain about how
your code looks when you do).

ChrisA



More information about the Python-list mailing list