On Sun, Nov 23, 2014 at 11:51 AM, Ron Adam <ron3...@gmail.com> wrote: > > > On 11/22/2014 06:20 PM, Chris Angelico wrote: >> >> Hmmm, there's no such thing as tuple comprehensions. > > Just didn't think it through quite well enough. But you are correct, that > would be a generator expression. > > One less case to worry about. :-)
Ah right, no probs. >>> >And it would be changed to this... >>> > >>> > def comp_expression(): >>> > for x in itr: # StopIteration caught here. >>> > if cond: >>> > list.append(expr) >>> > >>> > # StopIteration from cond and expr caught here. >>> > lst = list(x for x in comp_expression()) > > Right, the list.append() should be a yield(expr). In that case, your second generator expression is entirely redundant; all you want is list(comp_expression()). But the example doesn't say *why* this version should terminate on a StopIteration raised by expr, when the statement form would print an exception traceback. > The real question is how much breakage would such a change make? That will > probably need a patch in order to test it out. There's one attached here: http://bugs.python.org/issue22906 It doesn't create a __future__ directive, just applies the change globally. ChrisA _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com