[Tutor] Editing Pickled .dat files

ryan luna ryan_gm at sbcglobal.net
Sat Mar 4 12:31:16 CET 2006

Hello, this is like my 3rd question today lol which is
making up for not asking any for months =P, anyways
I have a pickled .dat file named dictionary, maybe
youv guessed this but its a dictionary of the
Alphabet, the program is a translator right now all it
does is translate the Alpabet (its a stupid made up
language helping someone out cuz i needed a project)
anyways im pretty sure i have the reading the pickled
file, taking input from the user, looking on the word
in the .dat file and printing out the translation, 
Here is where im stuck.
I want the program to be able to translate full words
to (the only way i know to do that is to put every
word in the dictionary, aka .dat file)
im not goin to put all the english words and there
translation in there myself! so i have a option for
the user to put there own definitions,
What i need to know is how do i take input from the
user, collect the word and its definitions and then
pickle it into the .dat but editing the dictionary in
the .dat file.
heres my code for reading so you get a better idea of
what i mean

pickle_file = open("dictionary.dat", "r")
        dictionary = cPickle.load(pickle_file)
        while sentence != "0":
            sentence = raw_input("\nInput a english
letter/word to be translated: ")
            if sentence in dictionary:
                definition = dictionary[sentence]
                print "\n", definition

More information about the Tutor mailing list