title: How do I check if stdin has some data?
body: <p>In Python, how do you check if <code>sys.stdin</code> has data or not?</p>
  
  <p>I found that <code>os.isatty(0)</code> can not only check if stdin is connected to a TTY device, but also if there is data available.</p>
  
  <p>But if someone uses code such as</p>
  
  <pre><code>sys.stdin = cStringIO.StringIO("ddd")
  </code></pre>
  
  <p>and after that uses <code>os.isatty(0)</code>, it still returns True.  What do I need to do to check if stdin has data?</p>