Another term for it is namespace, any variables declared in a function stay in a function, unless explicitly returned to the caller to prevent conflicts with other variables outside the given space. Other than using globals, what you can also do is set it up so X is filled with a returned value the function gives back that updates it with a new value, for example:

def my_fun(a):
    a = a + 1
    x = a
    return x

x = 3
x = my_fun(x)
print x

Keep in mind that if you use a return call in a function, the function will end and anything beyond the return call will be ignored, so be sure to put it at the end or in places where you want the function to end.

-BrushTone v1.3.0: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

Thumbs up


that's the one thing that got me while looking at code, globals. Okay. So that's what that does. Also there is a trick to reimport something, like this.
import thing
#do stuff with thing
#thing has been changed...
import thing
#new thing!

An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

Thumbs up