I think you are better off using a database in this situation, sqlite3 is a
good choice since no extra setup is required. See
http://docs.python.org/library/sqlite3.html

And to answer your question, the python pickle module can save class
instances, see http://docs.python.org/library/pickle.html


Regards,
Daniel Woodhouse

On Mon, Jul 13, 2009 at 5:21 PM, Thomas Scrace <t.scr...@gmail.com> wrote:

> Hi everyone,
>
> I am new to Python (and to programming) and, now that I have worked through
> most of Learning Python, I have set myself the exercise of writing a little
> text-based program to catalogue the contents of my CD collection.
>
> I have written enough code to allow me to create instances of an Album
> class with attributes like name, artist, year etc.  However, I am at a loss
> as to how to save these instances so that they can be retrieved the next
> time I run the program.  I assume I need to write them to a file somehow,
> and while I know how to write and read to and from files, I do not know how
> to write instances.
>
> I am sure this has an obvious and easy answer but I just cannot find it
> anywhere!
>
> If anybody could help I would be most grateful.
>
> Tom
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to