Re: [Tutor] Reading file and storing keys

2012-06-28 Thread Alan Gauld
On 28/06/12 01:19, moheem ilyas wrote: def tester(): fin = open('/home/moheem/Documents/words.txt', 'r') value = 0 wordDict = dict() for word in fin: wordDict[word] = value value = value + 1 fin.close() There seems to be a logical error. That is, when

Re: [Tutor] Reading file and storing keys

2012-06-27 Thread moheem ilyas
It was because I was testing with a large file. Thanks for your help/advice. On Wed, Jun 27, 2012 at 8:47 PM, Dave Angel wrote: > On 06/27/2012 08:38 PM, moheem ilyas wrote: > > Thanks. That makes sense, just failed to notice it. Btw, I tried printing > > out wordDict and Python became unrespons

Re: [Tutor] Reading file and storing keys

2012-06-27 Thread Dave Angel
On 06/27/2012 08:38 PM, moheem ilyas wrote: > Thanks. That makes sense, just failed to notice it. Btw, I tried printing > out wordDict and Python became unresponsive. Any ideas > Not without knowing how you tried it. Offhand, the only reason i can think of is that your were testing with a huge f

Re: [Tutor] Reading file and storing keys

2012-06-27 Thread moheem ilyas
Thanks. That makes sense, just failed to notice it. Btw, I tried printing out wordDict and Python became unresponsive. Any ideas On Wed, Jun 27, 2012 at 8:33 PM, Dave Angel wrote: > On 06/27/2012 08:19 PM, moheem ilyas wrote: > > I am working on a problem from a book, Think Python, which I thoug

Re: [Tutor] Reading file and storing keys

2012-06-27 Thread Dave Angel
On 06/27/2012 08:19 PM, moheem ilyas wrote: > I am working on a problem from a book, Think Python, which I thought would > be fairly easy. The problem is: > > Exercise 11.1. Write a function that reads the words in words.txt and > stores them as keys in a > dictionary. It doesn’t matter what the va

[Tutor] Reading file and storing keys

2012-06-27 Thread moheem ilyas
I am working on a problem from a book, Think Python, which I thought would be fairly easy. The problem is: Exercise 11.1. Write a function that reads the words in words.txt and stores them as keys in a dictionary. It doesn’t matter what the values are. Then you can use the in operator as a fast wa