[Python-3000] super(), class decorators, and PEP 3115

Guido van Rossum guido at python.org
Tue May 1 04:43:55 CEST 2007

On 4/30/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 05:38 PM 4/30/2007 -0700, Guido van Rossum wrote:
> >Of course, once the core language adds built-in support for such a
> >feature, it becomes slightly less advanced, and it is reasonable to
> >expect that the special functionality be provided by object or type or
> >some other aspect of the standard class definition machinery (maybe
> >even a default decorator that's always invoked).
> Yep.  That's precisely it.  I'm suggesting that since GF's, enhanced
> super(), and even potentially @abstractmethod have a use for such a hook,
> that this would be an appropriate hook to provide in object or type or
> whatever.  Or, have the MAKE_CLASS opcode just do something like:
>        ...
>        cls = mcls(name, bases, prepared_dict)
>        for decorator in cls.__decorators__:
>            cls = decorator(cls)
>        ...
> Heck, I'd settle for:
>        ...
>        cls = mcls(name, bases, prepared_dict)
>        for callback in cls.__decorators__:
>            callback(cls)
>        ...
> As this version would still handle all of my use cases; it just wouldn't be
> as useful for things like @abstractmethod that really do want to change the
> metaclass or bases rather than simply be notified of what the class is.

OK, put one of those in the PEP (but I still think it's a waste of
time to mention super). Though I think you may have to investigate
exactly what MAKE_CLASS does.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list