[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Classless Utilities?



On Saturday 13 May 2006 07:49, Kris Schnee wrote:
> so it can be called from anywhere. But if I use that trick of defining
> the class, then making an instance of it in the module itself, then that
> works; I'll have a reference available from the main program, anywhere.

i think that is an ok way to implement a singleton in Python.

just dont instanciate that class elsewhere, and it remains a singleton.as i 
understand Python does not need to be about elaborate constructs for simple 
things, but just doing the simple thing and trusting the programmer not be 
stupid (unless in some strange case use demands it is not a singleton, and 
then it is nice that no true singleton implementation is in the way, 
preventing several instanciations)

> Kris

~Toni