A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-November/010602.html below:

[Python-Dev] Making popen2 actually work

[Python-Dev] Making popen2 actually work [Python-Dev] Making popen2 actually workEric S. Raymond esr@golux.thyrsus.com
Tue, 14 Nov 2000 11:59:24 -0500
OK, so Guido told me at one point that 2.0 was supposed to have
included changes to the way buffering of I/O to subprocesses is
handled.  I've installed 2.0, and I need to know how to make the
following program work:

import os, sys

(child_stdin, child_stdout) = os.popen2("/usr/bin/rev", "t", 1);
print "* Child process spawned"

while 1:
    line = raw_input(">");
    child_stdin.write(line); child_stdin.flush()
    print "* Line written to child process"
    transformed = child_stdout.readline(); child_stdout.flush()
    print "* Line read back from child process."
    sys.stdout.write(transformed)

If anybody can tell me what the right magic is here, I'll write up 
a patch for the library docs explaining it and including the corrected
example.  This has to be a FAQ.
--
						>>esr>>



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