<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Sat, May 12, 2018 at 5:54 PM Cameron Simpson <<a href="mailto:cs@cskk.id.au">cs@cskk.id.au</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 06May2018 02:00, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>> wrote:<br>
>On 5 May 2018 at 13:36, Tim Peters <<a href="mailto:tim.peters@gmail.com" target="_blank">tim.peters@gmail.com</a>> wrote:<br>
>> If only one trailing "given" clause can be given per `if` test<br>
>> expression, presumably I couldn't do that without trickery.<br>
><br>
>I was actually thinking that if we did want to allow multiple assignments,<br>
>and we limited targets to single names, we could just use a comma as a<br>
>separator:<br>
><br>
>    if diff and g > 1 given diff = x - x_base, g = gcd(diff, n):<br>
>        return g<br>
><br>
>Similar to import statements, optional parentheses could be included in the<br>
>grammar, allowing the name bindings to be split across multiple lines:<br>
><br>
>    if diff and g > 1 given (<br>
>        diff = x - x_base,<br>
>        g = gcd(diff, n),<br>
>    ):<br>
>        return g<br>
<br>
I'm well behind, but... this! This turns "given" into a +0.8 for me.<br>
<br>
That's really nice. It reads clearly too.<br>
<br>
I was hitherto in the "expression as name" camp, which I gather is already <br>
rejected.<br></blockquote><div><br></div><div>I love given, but that's the one thing I don't like.  I prefer this:</div><div>    if (diff and g > 1 <br>            given diff = x - x_base<br>            given g = gcd(diff, n)):<br>        return g<br></div><div><br></div><div>—just like for and if subexpressions.   Doing this can also open up weirdness if someone tries to roll something like:</div><div><br></div><div>a = f(),  # Make a tuple of length 1</div><div><br></div><div>into a given statement.  Now, where do you up the parentheses?</div><div><br></div><div>given (</div><div>    a = (f(),),</div><div>    b = whatever?</div><div>)</div><div><br></div><div>Seems weird.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Cameron Simpson <<a href="mailto:cs@cskk.id.au" target="_blank">cs@cskk.id.au</a>><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
<br>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/CFuqwmE8s-E/unsubscribe" rel="noreferrer" target="_blank">https://groups.google.com/d/topic/python-ideas/CFuqwmE8s-E/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" rel="noreferrer" target="_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div></div>