I initialized rate as a global var:
import os, sys
rate=30
def foo():
print('#########rate:', rate)
if False:
rate=int(sys.argv[2])
foo()
but when running the script, I get the following error:
Traceback (most recent call last):
Line 10, in <module>
foo()
Line 5, in foo
print('#########rate:', rate)
UnboundLocalError: local variable 'rate' referenced before assignment
although the if False: rate=int(sys.argv[2]) statement is not executed, it seems has some influence, is there some python rules explains this?