How do I determine if sys.stdin is redirected from a file vs. piped from another process?
You're looking for stat
macros:
import os, statmode = os.fstat(0).st_modeif stat.S_ISFIFO(mode): print "stdin is piped"elif stat.S_ISREG(mode): print "stdin is redirected"else: print "stdin is terminal"