14.08.2013 Views

Tutorial slides (PDF) - Clemson University

Tutorial slides (PDF) - Clemson University

Tutorial slides (PDF) - Clemson University

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Subprocess<br />

The subprocess module allows the Python interpreter to<br />

spawn and control processes. It is unaffected by the GIL. Using<br />

the subprocess.Popen() call, one may start any process<br />

you'd like.<br />

>>> pi=subprocess.Popen('python -c "import math; print<br />

math.pi"',shell=True,stdout=subprocess.PIPE)<br />

>>> pi.stdout.read()<br />

'3.14159265359\n'<br />

>>> pi.pid<br />

1797<br />

>>> me.wait()<br />

0<br />

It goes without saying, there's better ways to do<br />

subprocesses...

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!