A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20171123/df975b75/attachment.html below:

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 23 November 2017 at 15:33, Stephen J. Turnbull <span dir="ltr"><<a href="mailto:turnbull.stephen.fw@u.tsukuba.ac.jp" target="_blank">turnbull.stephen.fw@u.tsukuba.ac.jp</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
However, my model of comprehensions is exactly a for loop that appends<br>
to an empty list repeatedly, but doesn't leak iteration variables.</blockquote><div><br></div><div>Not since Python 3.0. Instead, they create a nested function, the same way generator expressions do (which is why the name resolution semantics are now identical between the two cases).</div><div><br></div><div>The differences in structure between the four cases (genexp, list/set/dict comprehensions) then relate mainly to what the innermost loop does:</div><div><br></div><div>    result.append(expr) # list comp<br></div><div><div>    result.add(expr) # set comp</div><div>    result[k] = v # dict comp</div><div>    yield expr # genexp</div><div><br></div><div>Thus, when the expression itself is a yield expression, you get:</div><div><br></div><div><div>    result.append(yield expr) # list comp<br></div><div>    result.add(yield expr) # set comp</div><div>    result[k] = (yield v) # dict comp</div><div>    yield (yield expr) # genexp</div><div></div></div><div></div></div><div><br></div><div>Cheers,</div><div>Nick.<br></div></div><br>-- <br><div class="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</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