On Aug 21, 8:33 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2007-08-22, Karthik Gurusamy <[EMAIL PROTECTED]> 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.

Probably I should've put extra stress on the word "reuse".
The example quoted was trivial; if you replace the pipeline to have
say 5 processes, the advantage of not-reinventing the wheel becomes
more obvious.

I would call hand-crafting the pipe-setup an "overkill" when a very
good solution already exists to solve the problem. Yes, it may be
trivial to do; but not simpler than delegating to a shell.

Karthik


>
> --
> Grant Edwards                   grante             Yow!  I was born in a
>                                   at               Hostess Cupcake factory
>                                visi.com            before the sexual
>                                                    revolution!


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to