40 lines
966 B
Plaintext
40 lines
966 B
Plaintext
From: euroibc at solair1.inter.NL.net (Martin van Nijnatten)
|
|
Date: Wed, 21 Apr 1999 11:44:34 +0200
|
|
Subject: opening more than 1 file
|
|
References: <371CB255.5FCAFBAF@solair1.inter.NL.net> <371CBF75.10FA1EE6@mojam.com>
|
|
Message-ID: <371D9E02.B0511625@solair1.inter.NL.net>
|
|
X-UID: 309
|
|
|
|
Thanks, this answers my question.
|
|
Thanks, this answers my question.
|
|
|
|
|
|
Skip Montanaro 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?
|
|
>
|
|
> Well, how about:
|
|
>
|
|
> files = []
|
|
> for i in range(nfiles):
|
|
> files.append(open("/tmp/file%03d"%i, "wb"))
|
|
>
|
|
> then access the i-th file as files[i]?
|
|
>
|
|
> --
|
|
> Skip Montanaro | Mojam: "Uniting the World of Music"
|
|
> http://www.mojam.com/
|
|
> skip at mojam.com | Musi-Cal: http://www.musi-cal.com/
|
|
> 518-372-5583
|
|
|
|
|
|
|
|
|
|
|