an example of a singleton design pattern in python?

Aahz aahz at pythoncraft.com
Thu Jan 22 01:11:53 EST 2004


In article <mailman.625.1074734700.12720.python-list at python.org>,
Jeff Epler  <jepler at unpythonic.net> wrote:
>On Wed, Jan 21, 2004 at 07:38:26PM -0500, Aahz wrote:
>>
>> * Within a single module, use a global class as your singleton object.
>
>This is a little bit inconvenient, because you must either mark all
>methods as staticmethod (and refer to the class by name), or you must
>mark all methods as classmethod.

That's assuming one needs methods, of course; many times, the singleton
is just used for storing attributes.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

A: No.
Q: Is top-posting okay?



More information about the Python-list mailing list