From: euroibc at solair1.inter.NL.net (Martin van Nijnatten)
Date: Wed, 21 Apr 1999 11:43:43 +0200
Subject: opening more than 1 file
References: <371CB255.5FCAFBAF@solair1.inter.NL.net> <371CC329.F22B534F@pop.vet.uu.nl>
Message-ID: <371D9DCF.9ED0973A@solair1.inter.NL.net>
X-UID: 1194                                                  

Thanks, this answers my question.

I want to read the files, and they have to be open simultaneously because I
want to
merge the records/lines in the files into 1 file (after I made some changes
to certain fields)

Martijn Faassen wrote:

> martin van nijnatten wrote:
> >
> > I have a variable, which can have a value in the range from 1 to 20.
> >
> > If the value is 7, I have to open 7 files.
> >
> > What could be an elegant way of doing this?
>
> It's hard to say without more details -- what names do you want these
> files to have, for instance? Do you want to read the files, or write to
> them? The basic idea could be something like:
>
> def openfiles(howmany):
>     opened_files = []
>     for i in range(howmany):
>         opened_files.append(open("prefix%s" % i, "r"))
>     return opened_files
>
> This returns a list with file objects.
>
> Why is it necessary to open so many files simultaneously anyway? Perhaps
> I misunderstood. :)
>
> Regards,
>
> Martijn





