Jun 2
Cool Python Tricks!
A friend of mine recently started playing around with Python, and he asked me about a module I hadn’t heard of. I checked it out, and its pretty awesome. Its a new module, called subprocess, which was new in Python 2.4
Its pretty awesome, in that you can redirect the outputs in any which way, to another server, through a daemon program, to a file, anything.
Here’s a sample snippet to show how it works:
>>> import subprocess
>>> p=subprocess.Popen('ls -l', bufsize=10, shell=True)
>>> total 20
drwxr-xr-x 2 tyler tyler 4096 2008-03-25 20:31 admin
drwxr-xr-x 2 tyler tyler 4096 2008-03-25 19:42 admin_doc
drwxr-xr-x 3 tyler tyler 4096 2008-06-01 10:22 comics
drwxr-xr-x 2 tyler tyler 4096 2008-06-01 10:23 feeds
drwxr-xr-x 2 tyler tyler 4096 2008-04-18 14:43 panels
Anyway, if you make anything cool using this, let me know!
1 comment1 Comment so far
Good post.