title: Python: How to Call a function in another file with a circular import
body: <p>I am making a text-based floor game for learning purposes. I want all of the moving-around functions to be in a separate python file but I am having issues getting them to work together. </p>
  
  <p>I have the main game called <code>floors.py</code> and the map file is <code>floormap.py</code>.</p>
  
  <p>I can import and run functions from <code>floormap.py</code> inside of <code>floors.py</code> perfectly okay. </p>
  
  <p>But I do not know how to return to the <code>floors.py</code>functions after running a <code>floormap.py</code> functions. Here is an example below. When I run this, I get the following error in terminal:</p>
  
  <pre><code>NameError: global name 'first_hall_1' is not defined
  </code></pre>
  
  <p>I did get this working using: </p>
  
  <pre><code>from floormap import first_hall_1
  </code></pre>
  
  <p>But I could find a way to get the functions to once again be called in the original file. </p>
  
  <p>Floors.py:</p>
  
  <pre><code>import floormap
  
  def first_hall_object():
      grab = raw_input("Enter Command &gt; ")
  
      backward = ['back', 'Back', 'Backward', 'backward']
  
      if any (s in grab for s in backward): 
          first_hall_1()
  
  def walkin_hall():
      print "whatever"
  </code></pre>
  
  <p>floormap.py:</p>
  
  <pre><code>import floors 
  
  def first_hall_1():
      print "You are in front of the door again. It is locked."
      walkin_hall()
  </code></pre>