singleton objects with decorators
Michele Simionato
michele.simionato at gmail.com
Tue Apr 12 06:09:48 EDT 2005
Steven Bethard:
> It strikes me that I've never wanted or needed a singleton object.
> Would you mind sharing your use case? I'm just curious.
"Singleton" is the most idiotic pattern ever. If you want an instance,
just
instantiate your class once. If a class should have only one instance,
you can just document it. What I find usuful is "memoize", which
contains "Singleton" as a special case. So I use memoize even
for singleton would-be, i.e. logfiles and databases connections
(memoizing the connections, if I try to open a database twice with the
same parameters, I am returned an instance of the already opened
database).
Michele Simionato
More information about the Python-list
mailing list