Singleton class: what is the purpose?

Aahz aahz at pythoncraft.com
Thu Jun 5 09:31:12 EDT 2003


In article <mailman.1054811769.993.python-list at python.org>,
Gerrit Holl  <gerrit at nl.linux.org> wrote:
>
>What is a singleton class? What is the purpose of a singleton class?

I'd like to reinforce Aldo's point (very late in his post) that modules
are the canonical simple way to get singleton behavior in Python.  In
addition, if you'll only be accessing the singleton object from one
module (the one that creates it), use a class object (*not* an instance)
as your singleton.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra




More information about the Python-list mailing list