core_class_mro.py 453 B

123456789101112131415
  1. """
  2. categories: Core,Classes
  3. description: Method Resolution Order (MRO) is not compliant with CPython
  4. cause: Depth first non-exhaustive method resolution order
  5. workaround: Avoid complex class hierarchies with multiple inheritance and complex method overrides. Keep in mind that many languages don't support multiple inheritance at all.
  6. """
  7. class Foo:
  8. def __str__(self):
  9. return "Foo"
  10. class C(tuple, Foo):
  11. pass
  12. t = C((1, 2, 3))
  13. print(t)