[Python-Dev] @decoration of classes (original) (raw)
Phillip J. Eby pje at telecommunity.com
Tue Mar 29 04:44:59 CEST 2005
- Previous message: [Python-Dev] @decoration of classes
- Next message: [Python-Dev] Using descriptors to dynamically attach methods written in Python to C-defined (new-style) types
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 class K: metaclass = noconflict(MetaA, MetaB) # or @decoA @decoB class K: pass
Actually, it's possible today with:
class K: decoB() decoA()
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.
- Previous message: [Python-Dev] @decoration of classes
- Next message: [Python-Dev] Using descriptors to dynamically attach methods written in Python to C-defined (new-style) types
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]