Is there a way in Python to control the scope so that the variables in the calling functions are visible inside the called functions? I want something like the following
z = 1 def a(): z = z * 2 print z def b(): z = z + 1 print z a() print z b()
I would like to get the following output
2 4 2
The real solution to this problem is to simply pass z as a variable. I do not want to do this.
I have a large and complex code base with users of various levels of knowledge. They are currently trained to pass one variable, and now I have to add another. I do not trust them to pass the second variable sequentially through all the function calls, so I'm looking for an alternative that supports the interface. There is a good chance that this is not possible.
scope python
Mocklin
source share