How to get MRO in __new__() of metaclasses?
Frank von Delft
fvondelft at syrrx.com
Tue Dec 10 14:53:37 EST 2002
> > I strongly suspect there may be a better way of doing this. e.g.
> > doing the configuration in Deriv.__init__() instead of with class
> > variables, as in BadPrep (although I do want the configuration in
> > Deriv to be automatically inherited); or maybe with intelligent
> > exceptions? (Other suggestions?) But I rather like properties, and
> > at least I now grok metaclasses :-)
>
> I think the easiest way of doing what you want may be to create the
> class once, without frobbing, look at that to work out what you need
> to tweak, throw it away, and build another class.
No, there's more to those classes than that, so it's easier to be
selective...
> I also slightly fail to understand why you can't just scan through the
> immediate superclasses, but there may be something I've missed.
.... whereas this you're absolutely right about this - d'uh!!! Thanks
a stack, that was exactly what I was missing: the (bases) tuple *is*
the MRO of the about-to-be-created class, and there's no need to
blunder about the superclasses as I was doing, *because* that gives
the wrong MRO.
Thanks again! (and bless c.l.p. :-)
phx.
More information about the Python-list
mailing list