[Python-3000] Metaclass Vs Class Decorator

paul bedaride paul.bedaride at gmail.com
Mon May 19 19:34:17 CEST 2008


I think about it, and I think that it's two differents way of applying a
similar thing,
it's why I wonder, if this can't be good if metaclass and class decorator
have the same
interface, then we can use a class as a metaclass or as a decorator ??
paul bedaride
On Mon, May 19, 2008 at 6:10 PM, Guido van Rossum <guido at python.org> wrote:
> On Sun, May 18, 2008 at 8:36 PM, Raymond Hettinger <python at rcn.com> wrote:
> >>> It's why a want to know how to express the class decorator for making a
> >>> comparison
> >
> > [Georg]
> >>
> >> 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.
> >
> > I concur.
>> Technically, that's true, but an example wouldn't hurt. Examples also
> help understanding the motivation. Even the difference between class
> decorators and metaclasses could be explained with examples. (E.g. a
> metaclass that auto-registers its classes vs. a class decorator that
> registers a class.)
>> --
> --Guido van Rossum (home page: http://www.python.org/~guido/<http://www.python.org/%7Eguido/>
> )
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/paul.bedaride%40gmail.com
>-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-3000/attachments/20080519/d2fefc80/attachment-0001.htm>


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /