[Python-3000] super(), class decorators, and PEP 3115 (original) (raw)
Guido van Rossum guido at python.org
Tue May 1 04:43:55 CEST 2007
- Previous message: [Python-3000] super(), class decorators, and PEP 3115
- Next message: [Python-3000] Breakthrough in thinking about ABCs (PEPs 3119 and 3141)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 MAKECLASS opcode just do something like: ... cls = mcls(name, bases, prepareddict) for decorator in cls.decorators: cls = decorator(cls) ... Heck, I'd settle for: ... cls = mcls(name, bases, prepareddict) 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/)
- Previous message: [Python-3000] super(), class decorators, and PEP 3115
- Next message: [Python-3000] Breakthrough in thinking about ABCs (PEPs 3119 and 3141)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]