A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-March/043698.html below:

[Python-Dev] Re: Python-Dev Digest, Vol 8, Issue 91

[Python-Dev] Re: Python-Dev Digest, Vol 8, Issue 91Edward Loper edloper at gradient.cis.upenn.edu
Tue Mar 30 10:09:24 EST 2004
> Hi folks.
> 
> Earlier messages suggested a nice singleton decorator, which is shown
> in the draft PEP: [...]
> But i don't think this is a good way to write a singleton, because then
> the user of the class has to get instances by saying "MyClass" instead
> of "MyClass()".  

Depending on how you look at it, that might be a good thing.  In 
particular, it "documents" the fact that you're using a singleton, which 
might make your code easier to read/understand.  (You expect very 
different behavior from a singleton than from a normal class).

On a related note, now that Python has class methods, is there much 
point in a "singleton" pattern?  In particular, why not just make a 
class that only defines class methods, and uses the class namespace to 
store variables (instead of an instance namespace)?

-Edward


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4