From: skip at mojam.com (Skip Montanaro)
Date: Tue, 20 Apr 1999 17:53:10 GMT
Subject: opening more than 1 file
References: <371CB255.5FCAFBAF@solair1.inter.NL.net>
Message-ID: <371CBF75.10FA1EE6@mojam.com>
X-UID: 122                                                  

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




