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/2005-March/052477.html below:

[Python-Dev] @decoration of classes

[Python-Dev] @decoration of classes [Python-Dev] @decoration of classesDelaney, Timothy C (Timothy) tdelaney at avaya.com
Thu Mar 31 02:19:31 CEST 2005
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
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