do you master list comprehensions?
Matthew Moss
matthew.moss at gmail.com
Wed Dec 15 14:07:08 EST 2004
Diez B. Roggisch wrote:
> >>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
> >>> [e for l in data for e in l]
> ['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
Okay, I tried this in an interactive Python session and it works as
stated. My question is, why? How is the interpreter parsing that list
expression that it makes sense?
More information about the Python-list
mailing list