title: Python - 'module' object is not callable returned when calling function
body: <p>I am pretty new to Python, just learning it, and I am having trouble running my functions. I have a bit of a background in Matlab, so that may be where some of my confusion is coming from. </p>
  
  <p>This is the code that I have written in a script, using Notepad++ on my PC:</p>
  
  <pre><code>def print_order_numbers(amount):
  
      i = 0
      numbers = []
  
      while i &lt; amount:
          print("At the top i is %d" %i)
          numbers.append(i)
  
          i = i + 1
          print ("Numbers now: ", numbers)
          print("at the bottom i si %d" %i)
  
      print ("the numbers: ")
  
      for num in numbers:
          print (num)
  </code></pre>
  
  <p>Then when in python, after loading the function using:</p>
  
  <pre><code>from filename import print_order_numbers
  </code></pre>
  
  <p>However, because the function itself doesn't return anything and wasn't given an argument, this doesn't do anything. So when I try and call the function, like this:</p>
  
  <pre><code>print_order_numbers(2)
  </code></pre>
  
  <p>it gives me the error traceback:
  File "", line 1, in 
  NameError: name 'print_order_numbers' is not defined </p>
  
  <p>I have found that if I put this call in the same script as the function is written it, when I import the function, it runs it correctly. Why is my function recognized as a module by Python, and why does calling the function inside the script work?</p>
  
  <p>Is there any way to call the function in the python command window directly without having to put the call in the script where the function is? Matlab's functions allows you to do this and it would make things a lot easier, if I wanted to call a function from another script. (or would I just have to have the function in the same script as the rest of the code which calls upon it?)</p>
  
  <p>Sorry if this is a basic question, I just wish to understand this subject better, and have not been able to find a straight answer in all of the questions/tutorials I've looked through. Thanks in advance!</p>