On 22 November 2017 at 16:38, Ivan Levkivskyi <levkivskyi@gmail.com> wrote:
> On 22 November 2017 at 17:16, Paul Moore <p.f.moore@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...
The docs explicitly state that a new
scope is involved.