Hey, thanks for the help but when i try i get a error Bad file descripter, here is the code im using
elif choice == "2": pickle_file = open("dictionary.dat", "a") sentence = raw_input("Enter the word youd like to add: ") if sentence not in pickle_file: definition = raw_input("Whats the translated version: ") pickle_file[sentence] = definition print "\n\t'",sentence,"'", "Has been added to the dictionary." else: print "\n\tThat term already exists!" --- Liam Clarke <[EMAIL PROTECTED]> wrote: > Hi Ryan, > > Technically, you don't. > > You haul your dictionary out, as you're doing here - > > dictionary = cPickle.load(pickle_file) > > And when you're finished, you pickle it again. > > Regards, > > Liam Clarke > > On 3/5/06, ryan luna <[EMAIL PROTECTED]> wrote: > > 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 > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor