title: make variable global to multiple files in python
body: <p>I want to make a variable global to more than 2 files so that operating in any file reflects in the file containing the variable.</p>
  
  <p>what I am doing is:</p>
  
  <p><strong>b.py</strong></p>
  
  <pre><code>import a
  
  x = 0
  def func1():
      global x
      x = 1   
  if __name__ == "__main__":
      print x
      func1()
      print x
      a.func2()
      print x
  </code></pre>
  
  <p><strong>a.py</strong></p>
  
  <pre><code>import b
  
  def func2():
      print b.x
      b.x = 2
  </code></pre>
  
  <p>I have searched for threads here and find <code>from a import *</code> is making copies and <code>import a</code> is otherwise. I expect the code above to print <code>0 1 1 2</code>(sure it should be in new lines) when execute <code>python b.py</code> but it's showing <code>0 1 0 1</code></p>
  
  <p>How does one implement that?</p>