Hi Shuying!
Shuying Wang wrote: > Hi, > > I'm having problems understanding some code I came across: > > class Singleton: > __single = None > def __init__( self ): > if Singleton.__single: > raise Singleton.__single > Singleton.__single = self > > What does passing self to Singleton.__single do? I would say, this just sets the Singleton.__single to true and stores the reference to the only one allowed instance of the class. When the next time an instance of the class Singleton is requested an exception with the first instance of Singleton is thrown. Hope my explanation is clearly understandable in English Ewald _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor