tags:

views:

134

answers:

2

How do I do this?

+4  A: 

You can execute anything you want from Python with the os.system() function.

os.system(command)
Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system, and has the same limitations. Changes to os.environ, sys.stdin, etc. are not reflected in the environment of the executed command.

For more power and flexibility you will want to look at the subprocess module:

The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.

Andrew Hare
os.system unnecessarily invokes the shell. subprocess module is the way to do it in all cases, not just when you want power/flexibility.
nosklo
+2  A: 

Of course, Jython allows you to use Java classes from within Python. It's an alternate way of looking at it that would allow much tighter integration of the Java code.

Fortyrunner