Read handle concatenation

Jon Clements joncle at
Thu Nov 5 16:33:41 CET 2009

On Nov 5, 3:24 pm, kj <no.em... at> wrote:
> I want to be able to take two or more open read handles and
> concatenate them into an object that behaves like a regular read
> handle (i.e. a file object open for reading), but behind the scenes
> it reads from the concatenated handles in sequence.  I.e. I want
> the read-handle equivalent of the standard Unix utility cat.  (The
> reason I can't use subprocess and cat for this is that I want to
> concatenate read handles that do not necessarily come from files.)
> The only way I know to do this from scratch is straightforward but
> tedious, so I thought I'd better ask to see if there's already some
> module that would facilitate this task.
> TIA!
> kynn

Does the fileinput module do what you want?

More information about the Python-list mailing list