Variable scope in Python is very similar to that in C.
Functions can access any variable in its upper scope. It's a good feature for closure. However, It's not satisfying in some situation.
Let's use below code it demonstrate it.
def p():
print value
def echo(s):
print value # actually I want to write: print s
if __name__ == '__main__':
value = 0
s = 100
p() #0
echo(s) #0, it's hard to find the reason in execution
In above example, value is a module variable which maybe cause some subtle error.