title: Python module import NameError
body: <p>After doing research on this site and others, I create the topic. I have created a module like :</p>
  
  <p>module.py</p>
  
  <pre><code>def function(var1, var2):
      ...
      return(var3)
  </code></pre>
  
  <p>And the main code is :</p>
  
  <p>main.py :</p>
  
  <pre><code>import module 
  var4 = module.function(a, b)
  </code></pre>
  
  <p>When i launch the main file in IDLE, I have the following error :</p>
  
  <pre><code>NameError: name 'function' is not defined
  </code></pre>
  
  <p>I have also tried :
  main.py :</p>
  
  <pre><code>from module import function
   var4 = function(a, b)
  </code></pre>
  
  <p>And got a <code>module has no attribute 'function'</code></p>
  
  <p>Does someone have an idea of what's wrong ? When I tried to import constants from the same module I had this kind of error as well</p>