title: Importing module gives "name not defined" error even though the variable is defined before the import
body: <p>I have created a very basic script which I saved and can import into Python just fine and I have checked it works, yet I keep coming up with a &quot;name not defined error&quot; even though I have defined the variable before importing it - I have tried global command etc. and nothing.</p>
  <p><code>Seasons.py</code></p>
  <pre><code>if favorite_season == &quot;Winter&quot;:
      print(&quot;Let it snow!&quot;)
  </code></pre>
  <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; favorite_season = &quot;Winter&quot;
  &gt;&gt;&gt; import Seasons
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;C:\Users\Kaz\documents\Seasons.py&quot;, line 1, in &lt;module&gt;
      if favorite_season == &quot;Winter&quot;:
  NameError: name 'favorite_season' is not defined
  &gt;&gt;&gt;
  </code></pre>