This maybe a dumb question, but I'm gonna ask it anyways. I have a creature file and a simulation file, each contain a class of the same name. In the Simulation class's init, I need to initialize two Creature object. I have imported the creature file, but when I try creature.Creature() I get
Traceback (most recent call last): File "/Users/lego90511/Documents/workspace/creatureSim/simulation.py", line 2, in <module> import creature File "/Users/lego90511/Documents/workspace/creatureSim/creature.py", line 3, in <module> import simulation File "/Users/lego90511/Documents/workspace/creatureSim/simulation.py", line 86, in <module> sim = Simulation(5) File "/Users/lego90511/Documents/workspace/creatureSim/simulation.py", line 6, in __init__ self.creatures = {creature.Creature(4, 4, 3, 4, 4, 3, 10):"", creature.Creature(4, 4, 3, 4, 4, 3, 10):"", } AttributeError: 'module' object has no attribute 'Creature'" What am I doing wrong?
Here is the relevant code:
Simulation:
import creature from random import randint class Simulation(): def __init__(self, x): self.creatures = {creature.Creature():"", creature.Creature():"", } ... Creature:
class Creature: def __init__(self, social, intelligence, sensory, speed, bravery, strength, size): self.traits = [social, intelligence, sensory, speed, bravery, strength] ...