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/20171125/bc8fab44/attachment.html below:

<div dir="auto">I think the proposal is reasonable and won't require a PEP.</div><div class="gmail_extra"><br><div class="gmail_quote">On Nov 25, 2017 3:25 PM, "Terry Reedy" <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 11/25/2017 1:55 AM, David Cuthbert wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
First time contributing back -- if I should be filing a PEP or something like that for this, please let me know.<br>
</blockquote>
<br>
I don't think a PEP is needed.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Coming from <a href="https://bugs.python.org/issue32117" rel="noreferrer" target="_blank">https://bugs.python.org/issue3<wbr>2117</a>, unparenthesized tuple unpacking is allowed in assignments:<br>
<br>
  Â  Â rest = (4, 5, 6)<br>
  Â  Â a = 1, 2, 3, *rest<br>
</blockquote>
<br>
Because except for (), it is ',', not '()' that makes a tuple a tuple.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
but not in yield or return statements (these result in SyntaxErrors):<br>
<br>
  Â  Â return 1, 2, 3, *rest<br>
  Â  Â yield 1, 2, 3, *rest<br>
</blockquote>
<br>
To be crystal clear, a parenthesized tuple with unpacking *is* valid.<br>
<br>
  Â  Â  return (1, 2, 3, *rest)<br>
  Â  Â  yield (1, 2, 3, *rest)<br>
<br>
So is an un-parenthesized tuple without unpacking.<br>
<br>
Since return and yield are often the first half of a cross-namespace assignment, requiring the () is a bit surprising.  Perhaps someone else has a good reason for the difference.  Otherwise, +1 on the change.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The unpacking in assignments was enabled by a pre-3.2 commit that I haven't yet been able to track back to a discussion, but I suspect this asymmetry is unintentional. Here's the original commit:<br>
<a href="https://github.com/python/cpython/commit/4905e80c3d2f6abb613d212f0313d1dfe09475dc" rel="noreferrer" target="_blank">https://github.com/python/cpyt<wbr>hon/commit/4905e80c3d2f6abb613<wbr>d212f0313d1dfe09475dc</a><br>
<br>
I've submitted a patch (CLA is signed and submitted, not yet processed), and Serihy said that since it changes the grammar I should have it reviewed here and have signoff by the BDFL.<br>
</blockquote>
<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
While I haven't had a need for this myself, it was brought up by a user on StackOverflow (<a href="https://stackoverflow.com/questions/47272460/python-tuple-unpacking-in-return-statement/47326859" rel="noreferrer" target="_blank">https://stackoverflow.com/que<wbr>stions/47272460/python-tuple-<wbr>unpacking-in-return-statement/<wbr>47326859</a>).<br>
<br>
Thanks!<br>
Dave<br>
<br>
<br>
</blockquote>
<br>
<br>
-- <br>
Terry Jan Reedy<br>
<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/guido%<wbr>40python.org</a><br>
</blockquote></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