title: How can I run Python source from stdin that itself reads from stdin?
body: <p>I have a Python source file that looks like this:</p>
  
  <pre><code>import sys
  x = sys.stdin.read()
  print(x)
  </code></pre>
  
  <p>I want to invoke this source file by passing it to Python's stdin:</p>
  
  <p><code>
     python &lt; source.py
  </code></p>
  
  <p>After <code>source.py</code> is read, I want the Python program to start reading from stdin (as shown above).  Is this even possible?  It appears that the interpreter won't process <code>source.py</code> until it gets an EOF, but if an EOF is received, then <code>sys.stdin.read()</code> won't work.</p>