title: Sharing scope in Python between called and calling functions
body: <p>Is there a way in Python to manage scope so that variables in calling functions are visible within called functions?  I want something like the following</p>
  
  <pre><code>z = 1
  
  def a():
      z = z * 2
      print z
  
  def b():
      z = z + 1
      print z
      a()
      print z
  
  b()
  </code></pre>
  
  <p>I would like to get the following output</p>
  
  <pre><code>2
  4
  2
  </code></pre>
  
  <p>The real solution to this problem is just to pass z as a variable. I don't want to do this.</p>
  
  <p>I have a large and complex codebase with users of various levels of expertise.  They are currently trained to pass one variable through and now I have to add another. I do not trust them to consistently pass the second variable through all function calls so I'm looking for an alternative that maintains the interface.  There is a decent chance that this isn't possible.</p>