I've distilled down what I'm trying to do to the simplest form. I have a one module (prog1.py) that runs fine. A function in prog1.py accesses a variable (yy) OK without an error.
#prog1.py
def func():
print (yy)
return()
def main(yy):
print(yy)
func()
return()
#-----------------------------------------------
if __name__ == '__main__':
yy = 200
main(yy)
When I import that module into another module (prog2.py) the same function cannot access the variable (yy).
#prog2.py
import prog1
yy = 200
prog1.main(yy)
I get:
name 'yy' is not defined in line 3 in func.
What is the "correct" (python) way to do this?