creating new objects with references to them

JohnJSal johnjsal at
Thu Nov 2 17:51:39 CET 2006

JohnJSal wrote:

> Hope that makes sense. It seems like such a common task.

Ok, I'm thinking about the suggestion to make a list, but I'm still
confused. Even with a list, how do I access each instance. Would I have
to do it by index? I assume I'd do something like this:

self.records = []    # list for storing instances

Then when "New Record" is clicked:

def OnNewRecord(self, event):

But now what? There is still no reference to that instance? The only
thing I can think of is that each record will be a tab in a wxPython
notebook control, and each tab can be referenced by index. So whichever
tab I'm on, I can use that index to get that particular instance in the

But this solution seems too tied to my particular implementation. How
would you normally access these instances in the list?

Let's say there are three objects in the list. Someone fills out the
text fields for the second one and clicks "Save". I know how to read
all the information in the fields, but how do I then associate it with
that second instance?

(Or I wonder if I really even need to, since upon saving, the
information gets stored in the database immediately. Maybe I don't even
need a Researcher class at all.)

More information about the Python-list mailing list