Smalltalk and Python

Alex Martelli aleaxit at yahoo.com
Fri Dec 15 08:02:48 EST 2000


"Rainer Deyke" <root at rainerdeyke.com> wrote in message
news:M0f_5.27169$x6.14244092 at news2.rdc2.tx.home.com...
> "Greg Ewing" <greg at cosc.canterbury.ac.nz> wrote in message
> news:3A397778.2E6D84D3 at cosc.canterbury.ac.nz...
> > To mention something vaguely Python-relevant:
> > if Python had a convenient syntax for declaring
> > singletons, it could be a pretty good language for
> > Interactive Fiction...
>
> Meta-classes can turn a class statement into a singleton:
>
> class A(Singleton):
>   ...
>
> (where Singleton is an instance of the (meta-)class that implements
> singletons, not listed here because I haven't written or found it yet)
>
> It would be nice if the Singleton above was in module __builtin__ or at
> least somewhere in the standard library.

I beg to differ -- it's *great* that no such metaclass is anywhere
handy: the last thing we should do is encourage wider use of a
flawed design pattern.  It's bad enough that Singleton has such
a catchy name... it already makes it too-widely used!-)  (Please
see the 'direct printer access' thread for a post of mine, from a
few minutes ago, addressing this issue more directly).


Alex






More information about the Python-list mailing list