Thanks Michael and Ant.
--
http://mail.python.org/mailman/listinfo/python-list
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
Andy [EMAIL PROTECTED] writes:
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
Without looking at the docs, it seems save to assume
for line in inp:
lines +=1
# a list of words
tempwords = line.split(None)
if keyword.iskeyword(tempwords):
print tempwords
You are trying here to ask if a list of words (tempwords) is a
keyword. The error is due to the implementation of the iskeyword
function which
What you want is something like:
for line in inp:
lines +=1
# a list of words
tempwords = line.split()
for k in tempwords:
if keyword.iskeyword(k):
print tempwords
I think it should be:
if keyword.iskeyword(k):
print k
--
I think it should be:
if keyword.iskeyword(k):
print k
Whoops - yes of course!
--
http://mail.python.org/mailman/listinfo/python-list
Andy == Andy [EMAIL PROTECTED] writes:
if keyword.iskeyword(tempwords):
print tempwords
for word in tempwords:
if keyword.iskeyword(word):
print word
Ganesan
--
Ganesan Rajagopal
--
http://mail.python.org/mailman/listinfo/python-list
Andy wrote:
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).
It helps a lot of if you post