[Python-ideas] shutil.runret and shutil.runout

Serhiy Storchaka storchaka at gmail.com
Sun Feb 26 12:49:00 CET 2012

24.02.12 14:41, Nick Coghlan написав(ла):
> On Fri, Feb 24, 2012 at 10:13 PM, Mike Meyer<mwm at mired.org>  wrote:
>> Oddly enough, I read the Julia docs on external commands between my
>> first answer and your reply, and their solution is both as simple as
>> what you want, and safe.

Yes, I want this in Python:

readall(cmd('cut -d: -f3 $file', file='/etc/passwd') | cmd('sort -n') | cmd('tail -n5'))


cmd('cut', '-d:', '-f3', '/etc/passwd').pipe('sort', '-n').pipe('tail', '-n5').readlines()

or something similar.

> That *is* rather nice, although they never get around to actually
> explaining *how* to capture the output from the child processes
> (http://julialang.org/manual/running-external-programs/, for anyone
> else that's interested).

See readall and each_line.

More information about the Python-ideas mailing list