what are generators?

Miki miki.tebeka at gmail.com
Wed Mar 26 01:36:03 CET 2008


On Mar 24, 8:17 am, castiro... at gmail.com wrote:
> I'm looking for a cool trick using generators.  Know any exercises I
> can work?

Simple one the comes to mind is flattening a list:
>>> list(flatten([1, [[2], 3], [[[4]]]]))
[1, 2, 3, 4]
>>>

HTH,
--
Miki <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com



More information about the Python-list mailing list