[Tutor] updating Unix config file

Matt Herzog 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[3])[1]
> >
> >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

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.

> http://docs.python.org/library/subprocess.html#module-subprocess
> HTH,
> -- 
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

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 mailing list