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 keywords.iskeyword would
expect a string. You pass it a list.
> 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 = sum(1 for line in inp for w in line.split() if keyword.iskeyword(w))
'as
--
http://mail.python.org/mailman/listinfo/python-list