Singleton classes (with no such thing as static variables)

Duncan Booth duncan at NOSPAMrcp.co.uk
Mon Jul 2 09:06:54 EDT 2001


Giles Constant <gilesc at hyperlink-interactive.co.uk> wrote in
news:MdY%6.168$iF.4908 at news.lhr.globix.net: 

> I'm trying to make a class called "Environment" which will store some 
> global data such that all instances of the class have access to it. 
> The alternative is to create a single instance and pass it around every
> single object in the entire project, but it gets used so frequently
> that it would be rediculous.
> 
> Is there a way of doing this, or do I need a new paradigm? :-)
> 

The easiest thing here is to put your environment class in its own module, 
and simply make the shared data global to that module.


-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list