Singleton?

Alex Martelli aleax at aleax.it
Sun Jan 27 17:45:23 EST 2002


James T. Dennis wrote:
        ...
>  while still guaranteeing a singleton.  What I'd like to do is have
>  some sort of __instantiate__() member that would allow a class to
>  return a custom object reference.

It's there, in Python 2.2, and it's called __new__.  See
http://www.python.org/2.2/descrintro.html#__new__ for
an example of using it to implement Singleton.


Alex




More information about the Python-list mailing list