How do I capture piped text in python. For example something like this
cat foo.py | ./foo.py
in foo.py I have the following:
if __name__ == "__main__":
text = raw_input()
The problem is raw_input() terminates after the new line. How do I capture the whole thing as a string/list?
raw_inputis just a helper for prompting the user interactively. If you want to read any amount from stdin, usesys.stdin.read().