[Tutor] User Made Dictionaries

michael scott jigenbakuda at yahoo.com
Tue Mar 29 00:14:46 CEST 2011


Hello, I'm trying to find out the best course of action for the next stage of my 
program.

I want to hold information on various idols. I first thought to do this with 
classes, but realised that I could represent the data the same way with a 
dictionary. So I am now just concentrating on dictionaries. 


So lets say for example I wanted to have a dictionary with keys like this.

chiaki = { "name"             : "Chiaki Kuriyama",
                 "age"                : "26",
                 "charm_point" : "nose",
                 "profile_pic"     : 
"/home/jigenbakuda/Pictures/chiaki/chiaki.jpg",
                 "pic_quantity"  : 120,
                 "bio"                  : "First met this lady in kill bill, and 
the descent afterwards was horrible, I fan boy over this chick hard, etc..."}


I understand, or at least I have pretty good ideas about how to get this 
information (the keys and their values) from a user. 


I was thinking something like this for my general flow (this is all just fake 
code trying to represent my thought process)

mold =  { "name"              : " ",
                 "age"                : " ",
                 "charm_point" : " ",
                 "profile_pic"     : " ",
                 "pic_quantity"  : 0 ,
                 "bio"                  : " "}


chiaki = copy.copy(mold)
#have the user fill in the data here
natalie =  copy.copy(mold)
#have the user fill in the data here
# etc...


But my question is how do I repeatedly automate new names for the  dictionaries? 
Like how do I get the user to create the dictionary name  (chiaki, natalie, 
etc...)? 


Would it be better to represent this data with classes? If so, how do I have 
users create new class names? Ex. chiaki = Idol(), how do I get the user to 
create the chiaki name?

Any hints, answers, or links to recommended reading would be greatly appreciated 
:)


               

 ----
What is it about you... that intrigues me so?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110328/8aa3007b/attachment.html>


More information about the Tutor mailing list