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

Guido van Rossum guido at python.org
Fri Aug 6 17:55:31 CEST 2004


On pep 318 (like everything else here).

Is it actually supposed to work for classes? like the pep title says.

Like so many things in the PEP, it's out of date.

It doesn't seem to work, instead it issues a SyntaxError on the class keyword. Also, the discussion is completely focused on decorating functions and methods.

Some people have argued that it should work for classes (Java and C# decorators work for any declaration). I've never been convinced, although I'm not dead set against it either.

It would seem that the functionality isn't quite as useful there; you can get most of the same effects with metaclasses. I'm not aware of any idiom that takes a class and passes it through some kind of wrapper or transformation after the class declaration; if somebody is using this, it surely must be a very rare use indeed.

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



More information about the Python-Dev mailing list