Nick Coghlan <ncogh...@gmail.com> added the comment: "Just fix the issue" is easier said than done for the same reason that comprehensions were implemented the way they are now: lambda expressions still have to work.
That is, we need to maintain the invariant that: [x for x in iterable] {x for x in iterable} (k:v for k, v in iterable) (x for x in iterable) give the same results (respectively) as: [(lambda: x)() for x in iterable] {(lambda: x)() for x in iterable} ((lambda: k)():(lambda: v)() for k, v in iterable) ((lambda: x)() for x in iterable) Once you work through the implications of "We need the loop variable to visible to lexically nested scopes, but invisible in the containing scope", you're going to end up with something that looks enough like a nested function that the easiest to implement and explain option is to have it *be* a nested function. I'd be fine with a resolution that forbade yield expressions directly inside implicit scopes, though. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue10544> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com