singletons

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Fri Jul 18 07:38:51 CEST 2008


In message
<98eae1fc-ff34-4dcc-b46d-9e3da2850c28 at r66g2000hsg.googlegroups.com>, Craig
Allen wrote:

> On Jul 16, 7:01 pm, Lawrence D'Oliveiro <l... at geek-
> central.gen.new_zealand> wrote:
>>
>> >>> class TehLibrary(object) :
>>
>> ...     @classmethod
>> ...     def __new__(self, cls) :
>> ...         return self
>>
>> >>> s = TehLibrary()
>> >>> s == TehLibrary()
>>
>> True
> 
> That's great, I simply didn't find that when looking. Thanks!

Also note that

    s == TehLibrary

will be true (the instance equals the class). I assume that doesn't matter
for your purposes. :)



More information about the Python-list mailing list