user3519870
user3519870

Reputation: 81

Can't import classes Python

Here is my code

class Game_Events(Setup, Game_Setup):
   def __init__(self):
      super(Game_Events, self).__init__()

      super(Game_Events, self).game_setup(self.map_filename)

But when importing the classes I get:

TypeError: Error when calling the metaclass bases
Cannot create a consistent method resolution
order (MRO) for bases Game_Setup, Setup

Here is the init of Setup:

class Setup(object):
   def __init__(self):
    self.HERO_MOVE_SPEED = 20  # pixels per second
    self.MAP_FILENAME = 'resources/tmx/Fesnoria Town.tmx'
    self.MUSIC_FILENAME = "resources/music/Forest_Song.mp3"

Here is the init of Game_Setup:

class Game_Setup(Setup):
    def __init__(self):
       super(Game_Setup, self).__init__()

I need to import the Setup class first because this contains self.map_filename which I need for the other class below it.

Does anyone know how to fix this?

Upvotes: 0

Views: 75

Answers (1)

David Zwicker
David Zwicker

Reputation: 24278

Game_Setup is a subclass of Setup, but Game_Events is inheriting from both of them, which is not possible. I guess you should only inherit from Game_Setup to make it work.

Upvotes: 2

Related Questions