2009 210: Difference between revisions

From XPUB & Lens-Based wiki
 
Line 11: Line 11:
* [http://en.wikipedia.org/wiki/Comte_de_Lautr%C3%A9amont Comte de Lautréamont]
* [http://en.wikipedia.org/wiki/Comte_de_Lautr%C3%A9amont Comte de Lautréamont]
* http://www.gutenberg.org/etext/12005
* http://www.gutenberg.org/etext/12005
<source lang="python">
import re
words = re.split(r"\s+", text)
words = [w for w in words if w]
# print words
# print " ".join( [w.upper().encode("utf-8") for w in words if len(w) == 4] )
print " ".join( [w.lower().encode("utf-8") for w in words if w[0] == "e"] )
</source>

Latest revision as of 13:54, 31 March 2009

Morning

A small CGI exercise using List Comprehensions.

and of course, tutorials

Unicode

Text source:

import re
words = re.split(r"\s+", text)
words = [w for w in words if w]
# print words
# print " ".join( [w.upper().encode("utf-8") for w in words if len(w) == 4] )
print " ".join( [w.lower().encode("utf-8") for w in words if w[0] == "e"] )