I was googling for an example of the classic word frequency program in
Python as I'm just learning the language, and wanted to see how other
people implemented it.
I found this blog post
http://digitalhistory.uwo.ca/dhh/index.php/2006/08/20/easy-pieces-in-python-word-frequencies/
(with a much more concise version than I managed) but I can't seem to
find any mention in various Python documentation of the following
construct

wordfreq = [wordlist.count(p) for p in wordlist]

I would expect

for p in wordlist:
    wordfreq.append(wordlist.count(p))


I didn't know you could have an expression in the same line.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to