List objects are un-hashable

Andy andy.rockford at gmail.com
Fri Apr 27 03:50:37 EDT 2007


Hi, I'm trying to search and print any no# of Python keywords present
in a text file (say - foo.txt), and getting the above error. Sad for
not being able to decipher such a simple problem (I can come up with
other ways - but want to fix this one FFS). Any help is appreciated.
Thanks!!

import keyword, re, sys, string
inp = open("foo.txt", "r")
words,lines = 0, 0

for line in inp:
    lines +=1
    # a list of words
    tempwords = line.split(None)
    if keyword.iskeyword(tempwords):
        print tempwords

inp.close()




More information about the Python-list mailing list