[ x for x in xrange(10) when p(x) ]
Peter Otten
__peter__ at web.de
Sat Nov 12 02:12:43 EST 2005
bonono at gmail.com wrote:
> However, I found something interesting which I don't quite understand :
>
> list((x for x in [1,2,3] if x<2 or stop())) works
>
> but
>
> a = [ x for x in [1,2,3] if x <2 or stop() ] doesn't.
Here's how Carl Banks explained it to me when Bengt came up with this
trick.
http://mail.python.org/pipermail/python-list/2005-April/274051.html
Peter
More information about the Python-list
mailing list