At Wednesday 3/1/2007 19:38, meelab wrote:

I am looking for a way to create a "static object" or a "static class" -
terms might be inappropriate - having for instance:

class StaticClass:
    .
    .

and then
staticObject1 = StaticClass()
staticObject2 = StaticClass()

so that staticObject1 and staticObject2 refers exactly to the same
instance of object.

This is usually known as a Singleton.
If you only want it to store values, or use "normal" methods, the most direct way is a simple module - modules are already singletons in Python. If you want to include properties, descriptors, and such, look for the Singleton (or Borg) pattern in the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/


--
Gabriel Genellina
Softlab SRL

        

        
                
__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to