NEWBIE: Extending a For Statement.

Eduardo "EdCrypt" O. Padoan eopadoan at altavix.com
Mon May 21 15:08:33 EDT 2007


> > Perhaps you meant that second one to be:
> > (key, mydict[key] for key in mydict if key in xrange(60, 69) or key ==
> > 3)
> >
> Clearly not! Its called *list*-comprehension, not tuple-comprehension. ;)
With () instead of [], it is a generator expression.
http://docs.python.org/ref/genexpr.html



More information about the Python-list mailing list