On 22 November 2017 at 17:50, Paul Moore <p.f.mo...@gmail.com> wrote:
> On 22 November 2017 at 16:38, Ivan Levkivskyi <levkivs...@gmail.com> > wrote: > > On 22 November 2017 at 17:16, Paul Moore <p.f.mo...@gmail.com> wrote: > >> > >> Docs more importantly than PEP IMO. And are you implying that there's > >> a difference between generator expressions and comprehensions? I > >> thought both were intended to behave as if expanded to a function > >> containing nested for loops? Nothing said in this thread so far (about > >> semantics, as opposed to about current behaviour) implies there's a > >> deliberate difference. > > > > > > I think there may be a difference: > > > > comprehension `g = [(yield i) for i in range(3)]` is defined as this > code: > > > > __result = [] > > __i = None > > try: > > for __i in range(3): > > __result.append(yield __i) > > g = __result > > finally: > > del __result, __i > > Not in the docs, it isn't... Yes, since there is almost nothing there, this is what I _propose_ (or actually Serhiy proposed it first) > The docs explicitly state that a new > scope is involved. > But docs don't say it is a _function_ scope. The meaning of that statement (as I understand it) is just that the loop variable doen't leak from comprehension. -- Ivan
_______________________________________________ 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