I've succeeded in writing a dictionary ({}) that I can use as a small
personal phone book. The dictionary (very shortened and simplified)
looks like this in the script;

p = {}

p['bp1'] = 'xxx'
p['bp2'] = 'ooo'
p['ch'] = 'zzz'
p['me'] = 'aaa'
p['mg'] = 'vvv'
p['pu1'] = 'bbb'
p['pu2'] = 'ccc'
p['pw'] = 'kkk'

I have a function that enables the user to enter 'bp', for example,
and return both 'xxx' and 'ooo'.

(The keys are initials; I've disguised the values, each of which of
course are   name, home number, mobile number, speed dial number,
etc.)

But I'd like to put the lines of the dictionary in a text file so that
I can add key/value items to it by writing to it with another script.
I think I can do that, but I need some hints about how to get  the
script to access the text file in a way that lets the user look up a
phone number. I'm thinking that the script needs to recreate the
dictionary each time it's called, but I don't know how to do that.

Thanks,

Dick Moores
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to