title: What's the best way to tell if a Python program has anything to read from stdin?
body: <p>I want a program to do one thing if executed like this:</p>
  
  <pre><code>cat something | my_program.py
  </code></pre>
  
  <p>and do another thing if run like this</p>
  
  <pre><code>my_program.py
  </code></pre>
  
  <p>But if I read from stdin, then it will wait for user input, so I want to see if there is anything to read before trying to read from stdin.</p>