Python handles globals badly.

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Dec 4 06:35:52 EST 2014


jtan wrote:

> How can Skybuck use so much globals. Wouldn't that introduce a lot of
> thread safety problems?

Of course it would. But I expect that Skybuck probably doesn't even know
what threads are. Or if he does, he probably doesn't believe that they
should be used.

Thread safety is just the start of the problems with global variables:

http://c2.com/cgi/wiki?GlobalVariablesAreBad

Globals in Python are less bad than in many other languages, since they are
localised to a single module only. And the use of a few globals here and
there as needed is perfectly fine for small scripts. But using dozens of
them to avoid passing arguments to functions, that's just awful code.


-- 
Steven




More information about the Python-list mailing list