The subprocess extension to run processes.
>>>fromsubprocessimportrun>>>run('uname -r').stdout3.7.0-7-generic>>>run('uname -a').status0>>>printrun('rm not_existing_directory').stderrrm: cannotremove `not_existing_directory': Nosuchfileordirectory>>>printrun('ls -la', 'wc -l')
14To use pipe from the shell.
fromsubprocessimportrunrun('grep something', data=run.stdin)$ ps aux | python script.pyYou can install it from PyPi, by simply pip:
$ pip install subprocess.runto test it, launch python
>>>fromsubprocessimportrun- Python2.6
- Python2.7
- Python3.3
- PyPy2.1

>>> python setup.py test