Antoine Pitrou wrote:
That is, in your example:
>>> def f(x):
... if x > 5: raise StopIteration
...
>>> list(x for x in range(100) if not f(x))
[0, 1, 2, 3, 4, 5]
f() certainly shouldn't raise a StopIteration. There's no reason for doing
that, other than taking dirty implementation shortcuts and ending up with
difficult to maintain code.
I'm inclined to agree. This code seems to be designed
to cause the LC to exit early, which IMO is an abuse
of LCs. If you need a loop that doesn't run to
completion, you should write it out as a for-loop.
So no, this is not a bug, since in well-designed code
the difference in behaviour shouldn't matter.
--
Greg
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com