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
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