newb: object factory, and iteration

Chris iamlevis3 at hotmail.com
Wed May 12 12:22:22 EDT 2004


I'm developing a thing that gathers data as follows:
   1. For all files of a certain name:
      I. for all lines in each of those files:
         i. split the /-separated values in each of those lines,
            and stuff them into a list (or dict or whatever)

... and this is for a hundred or so such files of that name, with each
file having a hundred or so of such lines, with each line having 10 or
so of such /-sep'd values.

I thought that an instructive way of doing this would be to have a
class describing each of these files and their contents, and create a
new instance of this class for each file.  As I'm writing this, it
occurs to me that I could stick to a numbered naming convention (e.g.,
df1, df2, etc) for when I need to access this data later in the
program.  But is there a way for me to list all instances of a certain
class?  I.e., if the classname were FileInfo, and I had hundred
objects of that class, could I somehow loop:

  for all objects created from FileInfo
       do some stuff

TIA for any help.  I'll get used to Python sooner or later =)

-cjl



More information about the Python-list mailing list