Howegrown wordcount

Thomas Philips tkpmep at hotmail.com
Fri Jun 11 20:42:40 EDT 2004


An embarrassing mistake on my part: I should have typed
     #Treat iterable inputs differently
     if "__iter__" in dir(input):
         wordList =(" ".join([str(item) for item in input])).split()
     else:
         wordList = str(input).split()

I wish I knew how to treat all possible inputs in a uniform fashion,
but I'm nowhere near there as yet, hence the question. That said, it
addressess the situations that arise in practice fairly well, though I
am sure it can be sped up substantially.

Thomas Philips



More information about the Python-list mailing list