Re: [Tutor] Saving class instances

2009-07-14 Thread Alan Gauld
"Thomas Scrace" wrote Good to know I wasn't being totally dense. Now that I have got the pickle thing under my belt I am going to have a go at sqllite. Again, you might find the database topic ijn my tuorial a useful starting point for using SqlLite from Python... -- Alan Gauld Auth

Re: [Tutor] Saving class instances

2009-07-14 Thread Thomas Scrace
On 13 Jul 2009, at 22:04, "Alan Gauld" wrote: That's one way and you can find an example and some advice on how to handle subclassing in the OOP topic of my tutor. Wow; thanks! That tutorial was really useful, I will have to check out the rest of the site now. I am sure this has a

Re: [Tutor] Saving class instances

2009-07-13 Thread Alan Gauld
"Thomas Scrace" wrote 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, That's one way and you can find an example

Re: [Tutor] Saving class instances

2009-07-13 Thread Thomas Scrace
I think I will give both approaches a go, since this is just a learning exercise anyway. Thanks very much for your help. Oh, and sorry for accidentally quoting the whole digest last time. Won't happen again! Tom On 13 Jul 2009, at 17:53, tutor-requ...@python.org wrote: I think you are b

Re: [Tutor] Saving class instances

2009-07-13 Thread Daniel Woodhouse
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

[Tutor] Saving class instances

2009-07-13 Thread Thomas Scrace
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