473,395 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

os.popen--which one to use?

I'm confused by the number of variations on "popen" that Python offers.

I'm using os.popen in my programs without difficulty. Is this wrong?
Should I be using popen 2, popen3, etc.? I'm not clear on what the
advantages of popen2, 3 etc. are: they seem a lot more complicated.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Apr 3 '07 #1
5 1396
On Apr 3, 12:53 pm, Kevin Walzer <k...@codebykevin.comwrote:
I'm confused by the number of variations on "popen" that Python offers.

I'm using os.popen in my programs without difficulty. Is this wrong?
Should I be using popen 2, popen3, etc.? I'm not clear on what the
advantages of popen2, 3 etc. are: they seem a lot more complicated.

--
Kevin Walzer
Code by Kevinhttp://www.codebykevin.com

Check out subprocess. It's meant to be a replacement for all of the
above.

Apr 3 '07 #2
Kevin Walzer wrote:
I'm confused by the number of variations on "popen" that Python offers.

I'm using os.popen in my programs without difficulty. Is this wrong?
Should I be using popen 2, popen3, etc.? I'm not clear on what the
advantages of popen2, 3 etc. are: they seem a lot more complicated.
Use the subprocess module, instead. It makes all of the popen functions more or
less obsolete (it used to be called popen5 before it got moved into the standard
library).

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Apr 3 '07 #3
On Apr 3, 1:53 pm, Kevin Walzer <k...@codebykevin.comwrote:
I'm confused by the number of variations on "popen" that Python offers.

I'm using os.popen in my programs without difficulty. Is this wrong?
Should I be using popen 2, popen3, etc.? I'm not clear on what the
advantages of popen2, 3 etc. are: they seem a lot more complicated.

--
Kevin Walzer
Code by Kevinhttp://www.codebykevin.com
There's nothing wrong with using os.popen. Some of them are Unix
specific though. And that module's functionality along with os.system,
os.spawn and commands have all be integrated into the subprocess
module, which I think is much less confusing. The only places I've
seen a fairly coherent run-down of the os.popen modules is the "Python
in a Nutshell" book and maybe (I can't remember for sure) "Core Python
Programming".

See http://pydoc.org/2.4.1/subprocess.html for more info on the
subprocess module.

Mike

Apr 3 '07 #4
da********@yahoo.com wrote:
Check out subprocess. It's meant to be a replacement for all of the
above.
OK, I've done this. What is the benefit of subprocess? Improved
performance? It doesn't seem that way--in fact, os.popen has a
non-blocking mode, which subprocess seems to lack.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Apr 4 '07 #5
Kevin Walzer wrote:
da********@yahoo.com wrote:
>Check out subprocess. It's meant to be a replacement for all of the
above.

OK, I've done this. What is the benefit of subprocess?
Code that will work on most platforms and into the Python 3.0, when the popen*
zoo will disappear in favor of subprocess.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Apr 4 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.