newb: object factory, and iteration

Hornberger, Chris Chris.Hornberger at blackrock.com
Wed May 12 12:50:16 EDT 2004


Your object factory class will be responsible for creating your fileinfo object and associating a file to it, yes? Your factory object should be able to track them by adding them to a list upon creation. Upon completion of whatever operations, the fileinfo class(es) can notify the factory "I'm done" in which case the factory can remove it from the list and let normal reference counting and scoping cleanup take place.

--------------------------
Chris Hornberger
Blackrock - 302.797.2318
chris.hornberger at blackrock.com

Card carrying MSDN member since 2004.
No, really. I've got the card to prove it.


-----Original Message-----
From: python-list-bounces+chris.hornberger=blackrock.com at python.org
[mailto:python-list-bounces+chris.hornberger=blackrock.com at python.org]On
Behalf Of Chris
Sent: Wednesday, May 12, 2004 12:22 PM
To: python-list at python.org
Subject: newb: object factory, and iteration


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
-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list