473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
Jul 18 '05 #1
1 1246
Chris wrote:
But is there a way for me to list all instances of a certain
class?


I don't think there is, in general. If, as in your example, you can
modify the __init__ method of the class, you could add weak references
to created instances to a class member list. It would be even nicer,
though, to make a metaclass, instances of which maintain (weak)
references to instances of themselves.

Jeremy.
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gregg Altschul | last post by:
I have a Shared Object which its sole purpose is to create objects of a certain type and return a pointer to the object to the user. Therefore, the user becomes the owner of this object and is...
4
by: Donald Newcomb | last post by:
I'm a real Python NEWB and am intrigued by some of Python's features, so I'm starting to write code to do some things to see how it works. So far I really like the lists and dictionaries since I...
6
by: BBM | last post by:
I have an object that has a fairly complex construction sequence, so I have written a dedicated "factory" class that invokes the constructor of my object class (which does nothing but instantiate...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
16
by: Alex | last post by:
Hello, I'm trying to use a (remote) COM object from a PHP script (4.4, server has apache2 win32). The basics seem to work : I instantiate the COM object ($o = new COM"..."), then I use two of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.