directory という名前のモジュールと、種という名前の別のモジュールがあります。私が持っている種の数に関係なく、常に1つのディレクトリしかありません。
ディレクトリモジュールには、1つのディレクトリクラスがあります。Species モジュール内には、さまざまな種のクラスがあります。
#module named directory
class directory:
def __init__(self):
...
def add_to_world(self, obj, name, zone = 'forrest', space = [0, 0]):
...
#module named species
class Species (object):
def __init__(self, atlas):
self.atlas = atlas
def new(self, object_species, name, zone = 'holding'):
self.object_species = object_species
self.name = name
self.zone = zone
self.atlas.add_to_world(object_species, name)
class Lama(Species):
def __init__(self, name, atlas, zone = 'forrest'):
self.new('Lama', name)
self.at = getattr(Entity, )
self.atlas = atlas
問題は、私のクラスのそれぞれで、その種にアトラス オブジェクトを渡さなければならないことです。別のモジュールからインスタンスを取得するように種に指示するにはどうすればよいですか。
たとえば、クラス Entity を持つ Entity という名前のモジュールに 'atlas' のインスタンスがある場合、数行のコードですべての種に Entity からそのインスタンスを取得するように指示するにはどうすればよいですか?