[Tutor] updating Unix config file
msh at blisses.org
Tue Oct 20 16:44:16 CEST 2009
On Tue, Oct 20, 2009 at 08:29:59AM +0100, Alan Gauld wrote:
> "Matt Herzog" <msh at blisses.org> wrote
> >Anyway, I'd like a hint as to how I could convert this:
> >ifcfg_lines = os.popen("/sbin/ifconfig fxp0").readlines()
> >x = string.split(ifcfg_lines)
> >to the subprocess module. The os module is going away, right?
> The os module is not going away although the popen
> function might some day.
> However subprocess is currently the recommended way
> to do subprocess control and is more powerful and flexible
> than popen.
> Did you see the subprocess documentation page that
> shows how to do the equivalent of popen etc?
> Look down to section 184.108.40.206
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.
> Alan Gauld
> Author of the Learn to Program web site
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
The test of a first-rate intelligence is the ability to hold two opposed ideas in the mind at the same time, and still retain the ability to function.
-- F. Scott Fitzgerald
More information about the Tutor