title: Python name 'os' is not defined even though it is explicitly imported
body: <p>I have a module called <code>imtools.py</code> that contains the following function:</p>
  
  <pre><code>import os 
  
  def get_imlist(path):
      return[os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')]
  </code></pre>
  
  <p>When I attempt to call the function <code>get_imlist</code> from the console using <code>import imtools</code> and <code>imtools.get_imlist(path)</code>, I receive the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;input&gt;", line 1, in &lt;module&gt;
    File "C:\...\PycharmProjects\first\imtools.py", line 5, in get_imlist
  NameError: name 'os' is not defined
  </code></pre>
  
  <p>I'm new at Python and I must be missing something simple here, but cannot figure this out.  If I define the function at the console it works fine.  The specific history of this module script is as follows:  initially it was written without the <code>import os</code> statement, then after seeing the error above the <code>import os</code> statement was added to the script and it was re-saved.  The same console session was used to run the script before and after saving.  </p>