Assigning to lists with arbitrary names

Cliff Wells logiplexsoftware at earthlink.net
Wed Oct 10 13:01:17 EDT 2001


On Tuesday 09 October 2001 12:34, Stephen Boulet wrote:
> I can't quite figure out how to do this.
>
> I have 100 text files in a directory: file00.txt to file99.txt.
>
> I want to read each file in turn, parse it, and generate a list from
> each file.
>
> Here's the problem: I want to name each list list00 to list99. I don't
> want to do list[0] to list[99] (since each list is actually a list of
> lists, and I'd like to avoid a list of lists of lists  :).

How about a dictionary of lists of lists?

files = {}
for f in filenames:
    files[f] = myparser() # whatever you're doing to parse the file...


-- 
Cliff Wells
Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308




More information about the Python-list mailing list