I'd like to iterate two different iterators, something like this:
file1 = open('file1', 'r')
file2 = open('file2', 'r')
for item in one_then_another(file1, file2):
print item
Which I'd expect to print all the lines of file1, then all the lines of file2.
I'd like something generic, as the iterators might not be files, this is just an example. I know I could do this with:
for item in [file1]+[file2]:
but this reads both files into memory, which I'd prefer to avoid.
fileinput
is the one and only true solution.