I thought I'd 'got' globals but...

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Jul 6 15:51:57 EDT 2006


meridian a écrit :
> You mentioned earlier that
> "Modifying globals from within a function is usually a very bad idea."
> 
> Most of my app consists of functions or class/object functions, that's
> all I do in OOP.
> Did you mean that modifying globals from anywhere is bad? 

Yes, definitively. Even without concurrent access, it very rapidly turns 
the code into an unscrutable mess.

> or globals
> are bad? 

Mostly, yes.

As usual, this is not a hard rule but a guideline. But I use as few 
globals as possible, and almost all of them are read-only. The very few 
exceptions are dirty hacks, mostly called at init time.

> or don't code using methods/functions?  

Err...



More information about the Python-list mailing list