Normally, you process a file line by line in Python using a loop like:
import sys
for s in sys.stdin:
    # do something with the line in s
or
import sys
while True:
    line = sys,stdin.readline()
    if len(line) == 0: break
    # process input line
Of course, you can also use raw_input() in soemthing like this:
try:
    while True:
        s = raw_input()
        # process input line
except EOFError:
    # there's EOF.
Of course in all these cases, if there's no input ready to be read, the underlying read() operation suspends waiting for I/O.
What I want to do is see if there is input pending without suspending, so I can read until input is exhausted and then go do something else. That is, I'd like to be able to do something like
while "there is input pending":
    #get the input
but when no more input is pending, break the loop.
 
    