[Python-Dev] assigning to new-style-class.__name__

Samuele Pedroni pedronis@bluewin.ch
Wed, 27 Nov 2002 14:34:42 +0100


From: "Michael Hudson" <mwh@python.net>


> "Samuele Pedroni" <pedronis@bluewin.ch> writes:
>
> > > Michael Hudson <mwh@python.net> writes:
> > >
> > > > "Samuele Pedroni" <pedronis@bluewin.ch> writes:
> > > >
> > > > > I haven't looked at the code, but if it checks directly for the
> > consistency of
> > > > > E's mro when you change C's bases, then there is no way to move from
a
> > > > > hierarchy where A precedes B in the mros to one where the two are
> > swapped,
> > >
> > > Yes there is!  With A thru E as in my previous mail:
> > >
> > > C.__bases__ = (A,)
> > >
> > > D.__bases__ = (B, A)
> > >
> > > C.__bases__ = (B, A)
> > >
> > > Now there are situations where this can probably cause difficulties,
> > > but that's always going to be possible...
> >
> > what about solid bases? e.g. B is list and A  simply a subclass of object.
>
> Well, exactly.  I don't really care -- it's not like a generic "swap
> the order of these bases" function is going to be terribly useful.
>
> In that case, just setting C.__bases__ to (B,) first works, doesn't it?
>

You're right. In general one can reset all classes' bases to the solid base.
And then perform __bases__ assignments corresponding to the class statements
that would build the desired hierarchy. Happy end?

regards.