import select
r, w, x = select.select([sys.stdin], [], [], 0)
if r:
    print('READABLES:', r)
else:
    print('no pipe')
What's the best way to tell if a Python program has anything to read from stdin?