[Python-3000] Metaclass Vs Class Decorator

Georg Brandl g.brandl at gmx.net
Sun May 18 23:35:04 CEST 2008


paul bedaride schrieb:
> I see the peps 3115 and 3129 about metaclass and class decorators.
> 
> I think that the pep 3129 need to be improved for show the way to declare
> the decorator and not just the way to appy them.
> 
> I also wonder if we need this two things, and if that is not two way to 
> explain
> the same semantic.
> 
> It's why a want to know how to express the class decorator for making a 
> comparison

A class decorator works exactly like a function decorator, that is,

@foo
class X: ...

is equivalent to

class X: ...
X = foo(X)

This should be all you need to know in order to write a class decorator.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-3000 mailing list