How to get MRO in __new__() of metaclasses?

Jeremy Hylton jeremy at alum.mit.edu
Tue Dec 10 15:45:33 EST 2002


Michael Hudson <mwh at python.net> wrote in message news:<7h3d6oahyxe.fsf at pc150.maths.bris.ac.uk>...
> fvondelft at syrrx.com (Frank von Delft) writes:
> 
> 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.
> 
> Which seems a bit of a hack, but I can't think of a better way.
> 
> I also slightly fail to understand why you can't just scan through the
> immediate superclasses, but there may be something I've missed.

As a rule, it's hard to customize the way builtin type behaves in a
metaclass because none of the default behavior is exposed through a
metaobject protocol.  I imagine it would be much easier to write
metaclasses if type was implemented using a bunch of methods that
could be overridden in Python code.  This approach would be good for
metaclasses, but it make the already-complex type code more
complicated.

Jeremy



More information about the Python-list mailing list