Work around metaclass programming
Diez B. Roggisch
deets at nospam.web.de
Mon Oct 12 23:50:55 CEST 2009
Zac Burns schrieb:
> I have a class called Signal which is a descriptor. It is a descriptor
> so that it can create BoundSignals, much like the way methods work.
> What I would like to do is to have the class be a descriptor when
> instantiated in what will be the locals of the class, but not a
> descriptor everywhere else.
> Can I do this without requiring the class to use a special metaclass
> that does the transformation?
> One way I can think of which would work if there is such a thing would
> be a hook that type will call on the value of locals if that value is
> defined. That way I could just return the descriptor from that hook.
> The advantage of this over using a metaclass is that these are
> Am I making sense?
Not to me. What do you mean by "locals of the class", and how is a class
to be instantiated in them? Can you describe what your *usecase* for
More information about the Python-list