A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20101205/2ac8b2c7/attachment-0001.html below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#330033" bgcolor="#ffffff">
    On 12/5/2010 10:03 AM, <a class="moz-txt-link-abbreviated" href="mailto:skip@pobox.com">skip@pobox.com</a> wrote:
    <blockquote cite="mid:19707.54261.55334.594655@montanaro.dyndns.org"
      type="cite">
      <pre wrap="">
    Glenn&gt; On 12/4/2010 3:07 PM, Paul Moore wrote:
    &gt;&gt; The original goal was for subprocess to replace os.system, os.popen,
    &gt;&gt; os.spawn, etc. That's never quite happened because subprocess is just
    &gt;&gt; a little bit too conceptually complex for those basic tasks.

    Glenn&gt; Is that way?  I didn't find it particularly hard to learn, given


    Glenn&gt; the "cheat sheet" of techniques for doing the replacements.

For 99% of my usage (I suspect for most other peoples' as well, at least on


Unix-y systems), this is all I need:

    for line in os.popen("some pipeline"):


        do_stuff(line)

No cheat sheet necessary.  I don't see how subprocess could have made that


common idiom any simpler.  Maybe it's better at doing esoteric stuff,
however that falls into the 1% where a simple os.popen isn't adequate.

Skip


</pre>
    </blockquote>
    <br>
    So it couldn't make it any simpler.&nbsp; For your 99% usage, the
    question is, does it make it harder?&nbsp; And the answer is, at least a
    little bit... you have to type more...<br>
    <br>
    import subprocess<br>
    for line in subprocess.Popen("cmd", shell=True, stdout=PIPE).stdout:<br>
    &nbsp;&nbsp;&nbsp; do_stuff(line)<br>
    <br>
    Sad.&nbsp; It does seem like some wrapper functions could have been
    provided to make the easy cases at least as easy as they were
    before...<br>
    <br>
    My 99% case involves web servers and CGI-type interfaces.&nbsp; And
    subprocess doesn't provide quite enough to handle the job.&nbsp; It is a
    bit more complex than your pipeline case, and subprocess does allow
    the job to be done, and allows it to be done better than popen or
    popen2 could ever do it.&nbsp; But the helper functions I suggest in the
    issue would make it lots easier.&nbsp; And probably, it would be nice to
    include starting the threads within the helper functions, too.<br>
  </body>
</html>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4