2009/1/19 Vitor Bosshard <algor...@yahoo.com>:
> Are you even sure the list comprehension doesn't already shortcut evaluation?
>
> This quick test in 2.6 hints otherwise:
>
>
>>>> a = (i for i in range(10) if i**2<10)

Yes, but your test, once it becomes true, remains so. Consider

>>> list(n for n in range(10) if n%2 == 0)
[0, 2, 4, 6, 8]

I assume that the intention of the while syntax is:

>>> list(n for n in range(10) while n%2 == 0)
[0]

because 1%2 != 0 so the loop stops.

Having said that, I'm -1 on the proposal. The requirement is rare
enough that the correct place for it *is* in a module - and that's
what itertools provides (along with a number of other, equally valid,
manipulations). I certainly don't see it as justifying new syntax.

Paul.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to