[Tutor] calling other process?
ALAN GAULD
alan.gauld at btinternet.com
Mon Feb 9 02:20:17 CET 2009
> > > from subprocess import Popen
> > > output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0]
> Not to discount the Python Zen, but me thinks there could be a little more "Make
> easy things easy, and hard things possible"in this aspect of Python . :)
I sympatjise but to be honest I never use the backtick trick except at
the >>> prompt as a quick and dirty hack. It ranks alongside the _ variable
in my book as an interactive utility but it's too easy to miss or misread to use
in real code.
But even popen is easier, I agree, and I am still weaning myself away from
popen to Popen... But I can see the reasoning behind the move.
Of course if you do a lot of that you could always define a function
that supplies default values for everything but the command.
Alan G.
More information about the Tutor
mailing list