Feb-13-2019, 05:51 PM
This is how you run through the MRO:
class Top(object): def __init__(self): print('In class Top.') class Left(Top): def __init__(self): print('In class Left.') super(Left, self).__init__() class Right(Top): def __init__(self): print('In class Right.') super(Right, self).__init__() class Bottom(Left, Right): def __init__(self): print('In class Bottom.') super(Bottom, self).__init__() b = Bottom()
Output:In class Bottom.
In class Left.
In class Right.
In class Top.
You can't do that with __class__.__bases__, because Bottom will call Left and Right, and both of them will call Top, so Top will be called twice.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures