FAQ
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

Search Discussions

  • Robert Kern at Apr 3, 2007 at 6:58 pm

    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
  • Danmcleran at Apr 3, 2007 at 7:00 pm

    On Apr 3, 12:53 pm, 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.

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

    Check out subprocess. It's meant to be a replacement for all of the
    above.
  • Kevin Walzer at Apr 4, 2007 at 4:06 pm

    danmcleran at 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
  • Robert Kern at Apr 4, 2007 at 5:19 pm

    Kevin Walzer wrote:
    danmcleran at 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
  • Kyosohma at Apr 3, 2007 at 7:03 pm

    On Apr 3, 1:53 pm, 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.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 3, '07 at 6:53p
activeApr 4, '07 at 5:19p
posts6
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase