Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting return information from another python script

Tags:

python

linux

I'm on linux, and I have one python script that I want to call from another python script. I don't want to import it as a module (for a layer of security, and now for an academic exercise because I want to figure this out), I want to actually have one script call the other with os.system() or another function like that, and have the other script return a list of tuples to the first script.

I know this might not be the optimal way to do it, but I'd like to try it out, and learn some stuff in the process.

like image 740
Nathan Avatar asked Dec 27 '22 02:12

Nathan


1 Answers

You can use subprocess:

subprocess.call(["python", "myscript.py"])

This will also return the process return value (such as 0 or 1).

like image 96
Simeon Visser Avatar answered Jan 18 '23 05:01

Simeon Visser