subprocess.Popen howto?

norseman norseman at hughes.net
Fri May 8 13:32:34 EDT 2009


Carl Banks wrote:
> On May 7, 2:58 pm, norseman <norse... at hughes.net> wrote:
>> If you don't like a lot of typing that obscures the process,
>> take a look at os.Popen2  Pg.39 or so in Lib.pdf for 2.5.2
>> In this case - the popen3 is probably your best bet.
>>
>> I took a test run on "subprocess" a few months ago. My review:
>> excessive typing to accomplish the simple.
> 
> 
> Hmm, I won't argue that it can be excessive typing, but I think its
> purpose isn't to accomplish the simple but to hit all the corners of
> subprocesses.
> 
> What if you want os.system without the shell?  What if you want popen
> with the shell?  On Windows what if I want a subprocess without a
> console from a Python program in a console.  Stuff like that.
> 
Shell?  You lost me.
Why would you even use Windows?  Just kidding.
   Build the TSR and Start from Python or the bootup autostart
   and use it from Python or whatever.
Those in Unix, put the " &" after the program name in the starter
   to get it to background. Be sure to use P_NOWAIT in the starter.

> I still use os.system for Q&D stuff, but now use subprocess for
> everything else since I prefer thorough to short and sweet.

As long as speed (volume vs time) isn't a problem - OK.

> 
> 
> Carl Banks
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
==================================

         1)  That one has access to and can make for ones self choices is
               freedom.
         2)  As far as forcing a 'do all' into use is concerned,
               especially at the expense of removing others choices
               (Python notes say subprocess is supplanting popen et al),
               well... that is dictitorial, anti-freedom.
         3)  Consider this: a do all is as useful as driving a Ferrari on
               a Jeep Jamboree cross crountry race. Or chasing a Ferrari
               through paved mountain roads with a Jeep.  The SUV is
               supposed to be a "do all". Would you actually expect it to
               win either race?  After all, they are all "cars".
Use/create the proper tool for the job. I do not know any good mechanics 
that have a monkey-wrench (a crescent) in their tool box.  And all of 
them will tell you that the guy who picks one up and starts toward the 
car may be upset with the driver but he is not a mechanic.
(Wrong tool of choice. Besides, should not have been available. :)
(Use the long handle 1/2" socket drive ratchet. Weight, length and 
balance are just right. ;)

Everybody - Read #1 one more time and make it (speak out loud) "my way".
If the client is happy, who cares how it was done?  But don't force 
others ....  (Python admins taking notes?)

Steve




More information about the Python-list mailing list