opening more than 1 file
Martin van Nijnatten
euroibc at solair1.inter.NL.net
Wed Apr 21 05:44:34 EDT 1999
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
More information about the Python-list
mailing list