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
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com