[Python-Dev] @decoration of classes
Guido van Rossum
gvanrossum at gmail.com
Wed Mar 23 04:20:17 CET 2005
> I just noticed that decoration of classes was not included with the
> @decoration syntax that made it into Python 2.4. While I understand
> that class decoration was not a part of PEP 318, I remember people were
> interested in decorating classes for all sorts of reasons, among them as
> a prefix notation for documenting (which seems to nearly satisfy
> Nicholas Jacobson) as well as a partial metaclass replacement.
> Is the fact that it didn't make it into 2.4 due to a pronouncement that
> I missed/forgot, lack of time, or was it merely forgotten?
I don't recall whether I pronounced or not, but it is my opinion that
this isn't addressing nearly as big an issue for classes as it is for
functions/methods; in particular, the main problem of having all the
special handling *after* the body of the function doesn't occur for
classes, where you can put all the special handling at the top of the
body, perhaps aided by a crafty metaclass.
It would take a lot of convincing before I would think that class
@decorators are better than metaclasses.
In any case the fact that it wasn't in the PEP was plenty of reason
not to add it to 2.4.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev