OO question

fejkadress at hushmail.com fejkadress at hushmail.com
Mon Jan 1 04:47:12 CET 2007

I want to make an addressbook and I'm new to OO programming, so I
wonder if this sounds reasonable.

I think of making a class Address which contains all data about one
person, that class can have UserDict as baseclass so I can access data
like object['name'], etc..
Then maybe I can have a class AddressBook which has a list that
contains all those Address objects.
Does that sound reasonable?
And then the real reason that I posted here is:
If I want to save all addresses to disk, I can have a method, say,
save() of AddressBook. But then what? What is a good object oriented
approach? Should each Address object take care of saving itself to the
file, with a method like writetofile(filename), or should the class
AddressBook take care of the saving and ask each object for its data?


More information about the Python-list mailing list