[Python-Dev] @decoration of classes
Phillip J. Eby
pje at telecommunity.com
Tue Mar 29 04:44:59 CEST 2005
At 07:55 PM 3/28/05 -0500, Jack Diederich wrote:
>For compelling, I think the code smell put off by the "no conflict" metaclass
>generator recipe (which also appeared in Alex Martelli's PyCon talk) is fairly
>compelling from a duck typing point of view.
># would you rather
> __metaclass__ = no_conflict(MetaA, MetaB)
>class K: pass
Actually, it's possible today with:
As long as decoA() and decoB() use the "class advisor" mechanism I built
for Zope and PyProtocols.
That mechanism basically sticks a custom __metaclass__ into the enclosing
class, and implements a simple protocol for chaining subsequently-defined
class advisors. See 'protocols.advice' in PyProtocols or
'zope.interface.advice' in Zope or Twisted for details.
Anyway, I'm not certain that moving these functions up to decorator status
will really do anything useful; you can already put them near the top of
the class definition, such that they're relatively prominent.
More information about the Python-Dev