title: Python: Sharing global variables between modules and classes therein
body: <p>I know that it's possible to share a global variable across modules in Python. However, I would like to know the extent to which this is possible and why. For example, </p>
  
  <p>global_mod.py</p>
  
  <pre><code>x = None
  </code></pre>
  
  <p>mid_access_mod.py</p>
  
  <pre><code>from global_mod import *
  
  class delta:
      def __init__(self):
          print x
  </code></pre>
  
  <p>bot_modif_mod.py</p>
  
  <pre><code>import mid_access_mod
  import global_mod
  
  class mew:
      def __init__(self):
          global_mod.x = 5
  
  def main():
      m = mew()
      d = mid_access_mod.delta()
  </code></pre>
  
  <p>This prints None, even though all the modules are sharing the global variable x. Why is this the case? It seems like x is evaluated at mid_access_mod.py before it is assigned in bot_modif_mod.py by mew().</p>