title: Python module globals versus __init__ globals
body: <p>Apologies, somewhat confused Python newbie question. Let's say I have a module called <code>animals.py</code>.......</p>
  
  <pre><code>globvar = 1
  
  class dog: 
     def bark(self):
        print globvar
  
  class cat:
     def miaow(self):
        print globvar
  </code></pre>
  
  <p>What is the difference between this and</p>
  
  <pre><code>class dog:
     def __init__(self):
        global globvar
  
     def bark(self):
        print globvar
  
  class cat:
     def miaow(self):
        print globvar
  </code></pre>
  
  <p>Assuming I always instantiate a dog first?</p>
  
  <p>I guess my question is, is there any difference? In the second example, does initiating the <code>dog</code> create a module level <code>globvar</code> just like in the first example, that will behave the same and have the same scope? </p>