TypeError: Cannot create a consistent method resolution order (MRO)
This is the code which I plan to use for my game. But it complains for an MRO error. I don't know why. Can someone explains for me? Many thanks.
class Player: pass class Enemy(Player): pass class GameObject(Player, Enemy): pass g = GameObject()
GameObject is inheriting from
Enemy already inherits from
Player Python now cannot determine what class to look methods up on first; either
Player, or on
Enemy, which would override things defined in
You don't need to name all base classes of
Enemy here; just inherit from that one class:
class GameObject(Enemy): pass
Enemy already includes
Player, you don't need to include it again.
★ Back to homepage or read more recommendations: