2001 Enchancement Wishlist

Thomas Wouters thomas at xs4all.net
Sun Dec 31 11:59:40 EST 2000


On Sat, Dec 30, 2000 at 12:49:28AM +0100, Alex Martelli wrote:
> "Fredrik Lundh" <fredrik at effbot.org> wrote in message
> news:Ro736.2511$Qb7.273102 at newsb.telia.net...
>     [snip]
> > (fwiw, singleton classes are pretty unpythonic too.  python
> 
> Amen, Hallelujah.
> 
> > already has a framework for creating exactly one instance of
> > something: the module namespace).
> 
> Pity that isn't as flexible as an object-instance -- can't define
> special methods to determine how it will print, how it will
> let usercode loop on its items, etc.

Of course it can.

<spammodule.py>
class _singleton:
	<whatever you want>

SingleTon = _singleton()

All that is required is for everyone to use spammodule.SingleTon.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list