Nick Coghlan wrote: > # A decorator that does not alter its argument > def register(callable): > # Register the callable somewhere > ... > return callable > > # Decorated factory function > @register > def factory(): > pass > > # Post-decorated class > class factory: > pass > register(factory) > > # Metaclass > class RegisteredType(type): > def __init__(self, name, bases, dict): > super(self, RegisteredType).__init__(self, name, bases, dict) > register(self) > > class factory: > __metaclass__ = RegisteredType > > # Class decorator (not currently possible) > @register > class factory: > pass class factory: @register def __call__(self): pass Just as an additional data point - obviously not applicable in all cases. Tim Delaney
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