__mro__ — Easy Examples
Method Resolution Order; the order in which base classes are searched
Accessing __mro__
How to access and use __mro__.
python
# __mro__ print("Demonstrating __mro__") print(type(object).__dict__.keys())
__mro__ is a special attribute that method resolution order; the order in which base classes are searched.
__mro__ in practice
Using __mro__ in everyday code.
python
# More __mro__ examples print("__mro__ is a special Python attribute") # Every object has certain dunder attributes obj = object() attrs = [a for a in dir(obj) if a.startswith("__")] print(f"object has {len(attrs)} dunder attributes")
Understanding __mro__ helps you introspect and debug Python objects.
Want to try these examples interactively?
Open Easy Playground