m_travis
asked on
Return data from python script to another python scrip
I would like to call a python script from a different python script and pass the data back to the original on a windows machine.
Main python Script:
import OtherPythonScript
results = Execute OtherPythonScript
OtherPythonScript
do x:
record results to y
return y
Main python Script:
import OtherPythonScript
results = Execute OtherPythonScript
OtherPythonScript
do x:
record results to y
return y
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A little context would help to give the right advice for your case.
My first impression is, that for most cases pepr gave exactly the right answer. (especially if the script that you want to call is under your control). Just import and call the function
Some options you have are:
1) import the python script as module and execute the functions required (pepr's suggestion if you can modify the code)
2) Same as above but start in a separate thread
3.) import the other module and use the multiprocessing module for data exchange
3.) start script as a subprocess, collect it's stdout
4.) start the other script / process, write the results to a file and read the file when the script is finished
5.) start the other script as an RPC server (XMLRPC), and perform RPC calls
My first impression is, that for most cases pepr gave exactly the right answer. (especially if the script that you want to call is under your control). Just import and call the function
Some options you have are:
1) import the python script as module and execute the functions required (pepr's suggestion if you can modify the code)
2) Same as above but start in a separate thread
3.) import the other module and use the multiprocessing module for data exchange
3.) start script as a subprocess, collect it's stdout
4.) start the other script / process, write the results to a file and read the file when the script is finished
5.) start the other script as an RPC server (XMLRPC), and perform RPC calls
Maybe a little more context on your problem could help us to direct you better.