- Why is that.
- Process substitution works by creating a named pipe. So all the data consumed at the first open/read loop.
- Is there a way to do it without having to specify two input files.
- How about buffering the data before using it.
Here is a sample code
import sys
import StringIO
inputfile=sys.argv[1]
buffer = StringIO.StringIO()
# buffering
with open(inputfile, 'r') as f:
buffer.write(f.read())
# use it
buffer.seek(0)
for line in buffer:
print line
# use it again
buffer.seek(0)
for line in buffer:
print line