A
Andy
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()
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()