[Tutor] updating Unix config file

Tiago Saboga tiagosaboga at gmail.com
Tue Oct 20 16:49:53 CEST 2009


On Tue, Oct 20, 2009 at 2:44 PM, Matt Herzog <msh at blisses.org> wrote:
> Yes, thanks. What failed was the invocation of PIPE. Apparently I had to explicitly import PIPE from subprocess or python had no clue as to what PIPE was!
>
> Dare I say, "wtf?" since when fo I have to specify such? Shouldn't importing the subprocess module make all its methods available? I can't remember having to do this before.

It is really like any other module. If you just import subprocess, you
can access all its methods and attributes by spelling it out:

import subprocess
handler = subprocess.Popen(['cat'], stdout=subprocess.PIPE,
stdin=subprocess.PIPE)

Or you can import just the names you will use in the global namespace:

from subprocess import Popen, PIPE
handler = Popen(['cat'], stdout=PIPE, stdin=PIPE)

HTH,

Tiago Saboga.


More information about the Tutor mailing list