How to receive data from the environment, such as hitting

advertisements

How to read arguments from the shell, that some other program is streaming through a bash pipe? Secondly, is print i a proper way to stream data to the environment?

My search lead me trough os to the subprocess modules, but then: The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.

However, I do not want one program to spawn the other, thej sut need to write and read from a fifo.


This will read one line at a time from stdin and print it (you'd obviously do something else with the line, such as split() it into tokens or parse it some other way):

import sys

for line in sys.stdin:
    print line