You just import it.
#script2.py
from script1 import x
To make the script2 find the script1, the script1 file must be in the module search path
edit
Here's an example:
First we create a dir and display the value of the module search path:
$mkdir some_dir
$echo $PYTHONPATH
It's nothig. Then we create a file with the variable x
initialized to "hola" in that directory:
$cat >some_dir/module_a.py <<.
> x = "hola"
> .
And we create another python file to use it:
$cat >module_b.py<<.
> from module_a import x
> print x
> .
If we run that second script we got an error:
$python module_b.py
Traceback (most recent call last):
File "module_b.py", line 1, in <module>
from module_a import x
ImportError: No module named module_a
But, if we specify the some_dir in the module search path, and run it again, should work:
$export PYTHONPATH=some_dir
$python module_b.py
hola