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

Simon Percivall s.percivall at chello.se
Sat Aug 7 20:02:34 CEST 2004


I just wanted to say that I believe it should be allowed to decorate classes. There's not reason enough (reading the thread linked to by the PEP) to limit decorators this way. Like said several times in that thread, metaclasses are harder (to write and to understand) than decorators.

Also, considering that you said you would have actually wanted docstrings above the definition of a function, wouldn't this apply to classes as well?

Anyway, it's an artificial limit and it would be better to be able to test it out during the alpha.

//Simon

Guido van Rossum wrote: > > 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. >



More information about the Python-Dev mailing list