Showing content from http://mail.python.org/pipermail/python-dev/attachments/20171122/8b2e865a/attachment.html below:
<div dir="ltr">On 22 November 2017 at 17:16, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 22 November 2017 at 16:08, Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>> wrote:<br>
> On 22 November 2017 at 16:56, Yury Selivanov <<a href="mailto:yselivanov.ml@gmail.com">yselivanov.ml@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Wed, Nov 22, 2017 at 10:10 AM, Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>><br>
>> wrote:<br>
>> > On 22 November 2017 at 15:47, Paul Moore <<a href="mailto:p.f.moore@gmail.com">p.f.moore@gmail.com</a>> wrote:<br>
>> [...]<br>
>> I'm all for prohibiting using 'yield' expression in generator<br>
>> expressions or comprehensions. The semantics is way to hard to<br>
>> understand and hence be of any value.<br>
>><br>
>> Making 'await' a SyntaxError is absolutely not an option. Async<br>
>> generator expressions are a shorthand syntax for defining asynchronous<br>
>> generators (PEP 525), and it's already being used in the wild.<br>
><br>
><br>
> OK, makes sense, so it looks like we may have the following plan:<br>
><br>
> - fix `yield` in comprehensions<br>
<br>
</span>I'm still not clear what "fix" would actually mean, but you propose<br>
clarifying the docs below, so I assume it means "according to whatever<br>
the updated docs say"...<br>
<span class="gmail-"><br></span></blockquote><div><br></div><div>I mean the initial proposal: make comprehensions equivalent to a for-loop</div><div>Â </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> - update PEP 530 and docs re generator expressions vs comprehensions<br>
<br>
</span>Docs more importantly than PEP IMO. And are you implying that there's<br>
a difference between generator expressions and comprehensions? I<br>
thought both were intended to behave as if expanded to a function<br>
containing nested for loops? Nothing said in this thread so far (about<br>
semantics, as opposed to about current behaviour) implies there's a<br>
deliberate difference.<span class="gmail-"><br></span></blockquote><div><br></div><div>I think there may be a difference:</div><div><br></div><div>comprehension `g = [(yield i) for i in range(3)]` is defined as this code:</div><div><br></div><div>Â Â __result = []<br>
  __i = None<br>
  try:<br>
    for __i in range(3):<br>
      __result.append(yield __i)<br>
    g = __result<br>
  finally:<br>
    del __result, __i</div><div><br></div>while `g = list((yield i) for i in range(3))` is defined as this code:</div><div class="gmail_quote"><br></div><div class="gmail_quote"><span class="gmail-im">  def __gen():<br>
    for i in range(3):<br>
     yield (yield i)<br></span></div><div class="gmail_quote"><span class="gmail-im">
  g = list(__gen())</span></div><div class="gmail_quote"><div><br></div><div> Although these two definitions are equivalent in simple cases (like having `f(i)` instead of `yield i`)</div><div><br></div><div>But this is debatable, I think before we move to other points we need to agree on the clear definitions of semantics of generator expressions and comprehensions.</div><div><br></div><div>--</div><div>Ivan</div><div><br></div><div><br></div></div></div></div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4