Running another program via command-line from Panda3D

Apologies if this has already been talked about at length in the past.

I’ve had a quick search and couldn’t see exactly what I was looking for.

I’m trying to start another program using command line options from my python program, and I want my program to wait until the called program has finished and then continue.

I also want the command window to be hidden when it’s called.

Any suggestions as to how I should approach this?

Any help appreciated.


There are a couple options for calling Python programs from within python programs…

The simplest is the os.system command, which prints the output of the command to stdout.

Next is the commands module which you can use to get the exit status and output of the command you want to execute. I use this frequently, as it’s simple and hands the output right to me.

There’s also the subprocess module, which offers greater control over the execution of said command.

Finally, there’s the multiprocessing (part od stdlib in 2.6/3.0, but has been backported to 2.4/2.5)

So…those are your options for calling other Python programs (or running any system command, really) from within your code.