On 6/15/06, Akanksha Govil <[EMAIL PROTECTED]> wrote: > hi, > > I need to implement a singleton class in python. > Please give me some refernce sites which can help me with the same.
The online Python Cookbook is a good reference site. Here's the result from a search: http://aspn.activestate.com/ASPN/search?query=singleton&x=0&y=0§ion=PYTHONCKBK&type=Subsection I use the following from the printed edition of the Python Cookbook: class Singleton(object): """From the 2nd edition of the Python cookbook. Ensures that only one instance is created per running script""" def __new__(cls, *args, **kwargs): if '_inst' not in vars(cls): cls._inst = object.__new__(cls, *args, **kwargs) return cls._inst AndrĂ© > > Also i want to know to call a destructor for a singleton class. > > Thanks > Akanksha > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > > > _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
