Custom Popen.communicate Method Gives Wrong Output
Let's start by considering this code: proc_stdin.py import sys if __name__ == '__main__': for i, line in enumerate(sys.stdin): sys.stdout.write(line) test.py import s
Solution 1:
If you strip newlines from every line and then add them back between the lines, what happens to the last newline (if any)? (There’s no final, empty line after a final newline because your iter
discards it.) This is why Python’s readline
(or line iteration) function includes the newlines: they’re necessary to represent the end of the file accurately.
Post a Comment for "Custom Popen.communicate Method Gives Wrong Output"