I have two Python scripts in two different locations and cannot be moved. What is the best way to send information between the two scripts?
say for example in script1.py i had a string e.g.
x = ‘teststring’
then i need variable ‘x’ passed to script2.py, which saves the variable ‘x’ to a text file?
Any ideas?
You just import it.
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:
It’s nothig. Then we create a file with the variable
xinitialized to “hola” in that directory:And we create another python file to use it:
If we run that second script we got an error:
But, if we specify the some_dir in the module search path, and run it again, should work: