title: passing self to another classes function in self's function
body: <p>I have two classes, the first one has a function move(creature, board). Then in the creature class there is a function that calls move, so how do I pass the current creature to the move function while in the creature class? Should it just be move(self, self.board), because when I try that I get a "Undefined variable from import: 
   move" error?</p>
  
  <p>Here's the relevant code:</p>
  
  <p>Creature:</p>
  
  <pre><code>class creature: 
      def __init__(self, social, intelligence, sensory, speed, bravery, strenght, size):
          self.traits = [social, intelligence, sensory, speed, bravery, strenght]
          self.x = 0
          self.y = 0
          self.hunger = 10
          self.energy = 30
          self.shelter = 0
          self.dominance = 0
          self.boardSize = size - 1
          self.SOCIAL = 0
          self.INTELLIGENCE = 1
          self.SENSORY = 2
          self.SPEED = 3
          self.BRAVERY = 4
          self.STRENGTH = 5
   ...
   def performAction(self, action, location):
         ...     
         if action == "storeFood":
            food = location.vegetation
            location.vegetation = -1
            simulation.move(self, self.shelter)
            self.shelter.foodStorage += food
         ...
  </code></pre>
  
  <p>Simulation:</p>
  
  <pre><code>class simulation():
      def __init__(self, x):
          self.creatures = {creature.creature():"", creature.creature():"", }
          self.map = land.landMass
          self.lifeCycles = x
          self.runStay = ["rfl", "rbf", "rbl", "rbf", ]
          self.befriend = ["bbl", "bbf"]
          self.fight = ["fbl", "fbf", "bfl", "bff", "ffl", "fff"]
  ...    
      def move(self, creature, target):
              map[creature.x][creature.y].creatures.remove(creature)
              creature.energy -= abs(map[creature.x][creature.y].elevation - target.elevation) / creature.getSpeed() 
              target.creatures.append(creature)
              creature.x, creature.y = target.location
              ...  
  </code></pre>
  
  <p>EDIT:
  OK so I have somewhat solved the problem. Python requires that I have <code>simulation.simulation.map(self, self.shelter)</code> I'm assuming this means that it requires not just the class file but also an instance of that class. So the new question is do I have to make that instance somewhere else then pass it in? Or will this work with an instance of Simulation somewhere else?</p>