singleton in python ?
Alex Martelli
aleax at aleax.it
Mon May 6 03:54:12 EDT 2002
fritz steindl (-:fs) wrote:
> what is the best way to implement a singleton in python ???
Normally, a module is the best Pythonic singleton. If you really do need
to solve the forces met by Singleton (hardly anybody ever does when they
ask for Singleton -- they just ask for it out of habit), see:
http://www.aleax.it/Python/5ep.html
> i miss static variables and functions in python (or i don't see them :-)
Modules and top-level classes in a module normally exist in a single
copy and so does each of their attributes, be it callable or not.
Alex
More information about the Python-list
mailing list