[Tutor] Saving information for my program

michael scott jigenbakuda at yahoo.com
Mon Mar 21 16:11:49 CET 2011

I apologize now but I'm going to be spamming  the tutor list as I have just 
decided to create an extremely ambitious project for someone of my level. 
Anyhow, I will start with my first question.

How do I save user created information in python?

In my progam I will have users input various "attributes" of people they like 
(age, height, movies they have been in, songs they sung in, favorite part of 
them,  important links dealing with them, etc), and I'd like to know how to save 
these things so that even after you stop running the program they are saved and 
when you start the program again, these variables are loaded. This part of my 
program will be sort of like an offline-wiki-gui-thingie.

I was planning on using classes for each person so that I could store their 
attributes that way .
jessica = Profile()
jessica.name = "jessica ngorn"
jessica.age = 25
jessica.favorite_song = "chinpo no  uta"

I was thinking I have 2 options, which is save the information to a text file a 
write / read it in every session, but I have no idea how to do this with class 
attributes. I know how to do it for like a paragraph of text, but I have no idea 
how to do it with classes and their attributes.

The other option I was thinking about was using the pickle module. I have never 
used it, but I read the documentation, and I'm not exactly sure how to use it... 
it says it only saves the class "name", but not the body (same for functions), 
but how would that help me?

Well if you can contribute to helping me please do. Linking me to stuff to read 
is great, explaining it here is great, writing short example code is great too, 
anything helps.
What is it about you... that intrigues me so?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110321/0e6e90eb/attachment.html>

More information about the Tutor mailing list