List objects are un-hashable

Andy andy.rockford at
Fri Apr 27 09:50:37 CEST 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.

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


More information about the Python-list mailing list