Global Variables in OOP and Python

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sun Jan 1 10:55:58 EST 2006


On Sun, 01 Jan 2006 06:48:48 -0800, Kay Schluehr wrote:

>> Agree about from module import * being bad, but it is still generally poor
>> practice for the same reason using global variables is generally poor
>> practice.
> 
> No, I don't think so. The general wisdom is that global variables are
> bad not because they are global, but because they are variable.
> Responsibility about state mutation is scattered across the code and
> spaghetti is the likely consequence. This cannot be prevented by
> changing the access protocoll ( getters / setters ) or using static
> variables. Mutable OO-singletons are not less harmfull than good old
> globals.

Now that you mention it, how obvious it is. That is good thinking,
thanks.



-- 
Steven.




More information about the Python-list mailing list