I have a python script, script_a.py
which has a function:
def fun_a(n):
print (x/n)
I have another python script, script_b.py
which does the following
from script_a import fun_a
def fun_b(n):
fun_a(n)
def main():
global x
x=1
fun_b(1)
When I run script_b.py
from the terminal, I get the error that the x
variable does not exist in script_a.py
I do not understand why this is happening since I define x
to be a global
variable
Any ideas ?
EDIT
Adding this piece of code
def main():
global x
x=2
in script_a.py
also doesnt solve the problem