Sep-30-2019, 09:13 AM
Thx for the very quick reply. I had read that information already before, and I think that my "test" scripts are in line with what is recommended there. Still, it does not function as intended.
I have attached here my two scripts (the main script that is ran, and the imported script with the functions:
I have attached here my two scripts (the main script that is ran, and the imported script with the functions:
# this is file "testglobalsextmain.py" from testglobalsextimport import * global a,b,c a = "a" b = "b" c = "c" x = "?" print ("main ",a,b,c,x) d=f1(a) d=f2(a) b = "b2" d=f2(a) print ("end ",a,b,c,x) #and # this is file "testglobalsextimport.py" def f1(x): global a,b,c b = "f1b" c = "f1c" print ("f1 ",a,b,c,x) def f2(x): global a,b,c print ("f2 ",a,b,c,x)When I run the "main" script, I get this output:
Output:>>>
RESTART: G:\UserData\Willy\Documents\Willys_Programmas\Test_routines\testglobalsextmain.py
main a b c ?
Traceback (most recent call last):
File "G:\UserData\Willy\Documents\Willys_Programmas\Test_routines\testglobalsextmain.py", line 14, in <module>
d=f1(a)
File "G:\UserData\Willy\Documents\Willys_Programmas\Test_routines\testglobalsextimport.py", line 7, in f1
print ("f1 ",a,b,c,x)
NameError: name 'a' is not defined
>>>
Can anybody please tell me what I did wrong?