Chaining programs with pipe

Grant Edwards grante at
Wed Aug 22 05:33:52 CEST 2007

On 2007-08-22, Karthik Gurusamy <kar1107 at> wrote:

> Not sure on non-unix platforms, but in unix like platforms it's best
> to reuse shell's power.
>>>> import commands
>>>> commands.getoutput('ls | wc')
> '      4       4      24'

Executing a shell just because you want a pipe seems like a bit
of overkill.  Doing it the "right" way with subprocess is
pretty trivial.

Grant Edwards                   grante             Yow!  I was born in a
                                  at               Hostess Cupcake factory
                                 before the sexual

More information about the Python-list mailing list