[Python-Dev] Re: pep 318, Decorators for Functions, Methods and Classes (original) (raw)

David Abrahams dave at boost-consulting.com
Tue Aug 10 20:12:36 CEST 2004


Skip Montanaro <skip at pobox.com> writes:

(still catching up...)

Simon> I just wanted to say that I believe it should be allowed to Simon> decorate classes. There's not reason enough (reading the thread Simon> linked to by the PEP) to limit decorators this way. Like said Simon> several times in that thread, metaclasses are harder (to write Simon> and to understand) than decorators. While it might be perceived as a limitation there's nothing preventing its addition in a later version if warranted. I believe most/all the various proposals on the PythonDecorators wiki, not just the pie syntax, could be easily adapted to class decoration.

I was going for replacing the module's dict with a dict subclass, and hooking setitem it as an alternative to using settrace to implement this. It's not allowed, though :(. We also need a way to say, "replace the dict into which new definitions are falling" so we can implement decorators inside of class definitions.

-- Dave Abrahams Boost Consulting http://www.boost-consulting.com



More information about the Python-Dev mailing list