[EMAIL PROTECTED] wrote: > 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 In Python 2.4 or 2.5 you can subclass dict.
> 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? Yep. class AdressBook(list): def save(self, filename): import pickle ... > 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? If you use the pickle module on the Addressbook then it will automatically save each Address instance. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list