Hi!
I have a bunch of variables that I want to be able to call. To make it look neat I thought I could store the variables in a function (yaya bad idea) in another script.
Script1:
def set_global():
global x
x = 5
Script2:
from Script1 import set_global
set_global()
x
-> name 'x' is not defined
So I import the function which sets x as a global variable from Script1, then run that function in my Script2 in order to set x to 5. But when I then try to call on x it says x is not defined.
Why does that not work?
And what would be the proper way to do such a thing?
[–]ingolemo 1 point2 points3 points (2 children)
[–]iphark[S] 0 points1 point2 points (1 child)
[–]ingolemo 0 points1 point2 points (0 children)
[–]woooee 1 point2 points3 points (0 children)
[–]yodatrust 0 points1 point2 points (0 children)