A RetroSearch Logo

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

Search Query:

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

[Python-Dev] PEP 318 - generality of list; restrictions on elements

[Python-Dev] PEP 318 - generality of list; restrictions on elementsShane Hathaway shane at zope.com
Mon Mar 8 17:34:18 EST 2004
Fred L. Drake, Jr. wrote:
> As an (admittedly trivial) example, I'd be quite happy for:
> 
>     class Color [valuemap]:
>         red = rgb(255, 0, 0)
>         blue  = rgb(0, 255, 0)
>         green = rgb(0, 0, 255)

Ooh, what about this:

     def singleton(klass):
         return klass()

     class MyThing [singleton]:
         ...

That would be splendid IMHO.

However, since MyThing instances aren't necessarily callable, I think my 
code breaks the rule Aahz is proposing.  The 'singleton' decorator has 
to come last in the decorator list.  Also note that the 'singleton' 
function is not a decorator in the design pattern sense, since the 
output (an instance) does not implement the same interface as the input 
(a class).

Shane

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