[Tutor] Popen problem with a pipe sign "|"

Tim Golden mail at timgolden.me.uk
Mon Jul 6 16:27:02 CEST 2009

hyou wrote:
> Thanks for the answer! I found the problem was because I put the 2nd
> argument to Popen with Shell = true. Though I'm not sure why it doesn't work
> with Shell = true while the same setting works for other commands.

There's a long-outstanding bug when shell=True is passed to
subprocess.Popen on Windows such that the rest of the line
isn't quoted correctly (ie doesn't cope with special chars
such as space, pipe and ampersand).

In general, you almost never need to pass shell=True on
Windows. The latest docs have just been updated with a
patch I wrote to that effect, but it basically says:
don't use shell=True unless you know you need to.


More information about the Tutor mailing list