Python handles globals badly.
tdev at freenet.de
tdev at freenet.de
Wed Sep 2 18:25:46 EDT 2015
Reflecting the answers I want to add following:
Considering class usage is something I thought about
but is not the way I want use Python so far.
If so, I could stay on oo-scripting languages as well.
It is the good idea of Python about modules which are singletons
and therefore have already its state (so in some way they are already somehow
like classes - except the bad annoying thing with the "global" statement).
That said, it is not an overusing of globals cause globals are module vars only.
Or have you never written singletons or other classes in e.g Java, C++ with
lots of static and class members and methods using this members.
With globals in Python are not meant traditional globals (app spanning vars) as already said.
Globals in Python are like class-members and statics in OO-languages. Globals are module scope!
And therefore it is not the devil or evil problem or code desaster problem
or LUA's opposite approach.
(local/nonlocal statements I think are needed cause of lambda functionality and
is not what I try to discuss here)
Hopefully this clarifies a bit more my point of view and you can
now agree that using "global" is not only over-regulated but also ugly code.
At least the developer should be free to use the "global"-statement
(if one really need this?) or not (myself, and hopefully a lot other).
Therefore still hoping a new PEP will arise.
@Mark Lawrence
This response I have not checked. Can you provide arguments or clarify your statement?
More information about the Python-list
mailing list