singletons

Craig Allen callen314 at gmail.com
Thu Jul 17 06:25:01 EDT 2008


On Jul 16, 7:01 pm, Lawrence D'Oliveiro <l... at geek-
central.gen.new_zealand> wrote:
> In message
> <e2ef1d2c-f39b-43e2-a848-0cb7660fd... at l42g2000hsc.googlegroups.com>, Craig
>
> Allen wrote:
> > ... the ideal is still that
>
> > tl = TehLibrary() would always return the same object.
> >> 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!



More information about the Python-list mailing list