<div><div dir="auto">Fair enough. I will. Sorry for the extra pressure at this particular stage.</div></div><div><br><div class="gmail_quote"><div dir="ltr">On Mon, 9 Jul 2018 at 00:06, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Since you CC'ed me explicitly I feel compelled to respond. I have read your reasoning, and I simply don't agree with it. A few months ago I would have happily explained why (there is a reason) but given the endless debate we've already seen I am simply too tired for another long email. Please give me the benefit of the doubt. The sky is not falling.<br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Jul 8, 2018 at 2:27 PM Giampaolo Rodola' <<a href="mailto:g.rodola@gmail.com" target="_blank">g.rodola@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, Jul 8, 2018 at 7:24 PM Chris Angelico <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>> wrote:<br>
><br>
> On Mon, Jul 9, 2018 at 3:14 AM, Giampaolo Rodola' <<a href="mailto:g.rodola@gmail.com" target="_blank">g.rodola@gmail.com</a>> wrote:<br>
> ><br>
> ><br>
> > On Sun, Jul 8, 2018 at 6:45 PM Steve Holden <<a href="mailto:steve@holdenweb.com" target="_blank">steve@holdenweb.com</a>> wrote:<br>
> >><br>
> >> On Sun, Jul 8, 2018 at 10:41 AM, Giampaolo Rodola' <<a href="mailto:g.rodola@gmail.com" target="_blank">g.rodola@gmail.com</a>><br>
> >> wrote:<br>
> >>><br>
> >>> [...]<br>
> >>> I find that (space between the parentheses of a function call statement)<br>
> >>> too unnatural as a place where to put an assignment. It is not even<br>
> >>> "guarded" by a keyword like "if" or "while" which can help as indicators<br>
> >>> that an assignment may occur. Also, I think it's way too easy to confuse it<br>
> >>> with a keyword argument:<br>
> >>><br>
> >>> >>> foo(x = 1) # keyword arg<br>
> >>> >>> foo(x := 1) # assignment + value passing<br>
> >>> [...]<br>
> >><br>
> >><br>
> >> But the PEP 8 spellings are<br>
> >><br>
> >> foo(x=1)<br>
> >><br>
> >> and<br>
> >><br>
> >> f(x := 1).<br>
> >><br>
> >> The extra spacing makes it obvious that this isn't a regular named<br>
> >> argument.<br>
> ><br>
> ><br>
> > What if the author of the code I'm reading didn't respect PEP-8? I don't<br>
> > think it's fair to invoke PEP-8 as a counter-measure to obviate a syntax<br>
> > which can clearly be mistaken with something else simply by omitting 2<br>
> > spaces. Not to mention that I don't see why anyone would want to declare a<br>
> > variable in there in the first place.<br>
> ><br>
><br>
> It's not about why someone would want to assign inside a function<br>
> call. It's about why it should be forbidden. Perhaps nobody has a good<br>
> reason to use THlS_OBJECT as a variable name, and it's potentially<br>
> very confusing; but should the grammar of Python forbid it? No.<br>
> Because there is no value in forbidding it.<br>
<br>
I'll try to give some reasons on why I think it should be forbidden.<br>
In order of importance, more or less:<br>
<br>
1) Because of readability and because it's ambiguous. foo(x := 1) and<br>
foo(x = 1) are visually too similar and mean 2 completely different<br>
things. And no, I don't think PEP-8 compliant variants are much<br>
better:<br>
>>> foo(x := 1)<br>
>>> foo(x=1)<br>
Good luck explaining the difference between the two to a beginner<br>
including the introduction of PEP-8 concepts and why spaces are so<br>
important in this case. The fact that spaces are more important here<br>
than in other places alone makes me think this is unlikely a good<br>
idea.<br>
<br>
2) It's an incentive to write more compact code at the expense of<br>
readability. I see := being used in "if" and "while" statements as<br>
different in this regard. They imply an indented code block will<br>
follow and the variables being set in the "if/while" statement will be<br>
used right after that, supposedly in the very next line and *in that<br>
block only*. This is what<br>
<a href="https://github.com/python/cpython/pull/8122/files" rel="noreferrer" target="_blank">https://github.com/python/cpython/pull/8122/files</a> is all about,<br>
really. There is no block in this case hence AFAICT this syntax is<br>
only meant for writing one-liners.<br>
<br>
3) := assignments in {if, while, yield, assert} statements are more<br>
clearly noticeable because delimited by such keywords whereas a<br>
function call can appear anywhere in the code. The only way to easily<br>
track assignments such as foo(x := 1) is via linting.<br>
<br>
4) IMO this is the main bit of PEP-572 which can be subject to serious<br>
abuse. The value of "explicit is better than implicit" is an advanced<br>
concept. We can't expect it can be grasped by everybody. Many folks<br>
may be tempted to write one-liners at the top of a function and even<br>
feel good about it because a bunch of lines were saved. Potentially *a<br>
lot* of lines can be saved so it even more advanced users may be<br>
tempted to use it. After all the language allows it + "it's brand new<br>
syntax so it must be good".<br>
<br>
5) It has no keyword argument correspondence. If foo(x := 1) is<br>
allowed then why this one is not?<br>
>>> foo(x=(x := 1))<br>
(I don't think it should BTW: it's not pretty)<br>
<br>
6) Differently from := usage in {if, while, comprehensions} no valid<br>
use case which would justify its usage has been provided so far.<br>
AFAICT the only valid use case is for writing one-liners.<br>
<br>
7) Defining something in there just feels wrong (to me at least)<br>
<br>
8) I'm pretty sure any linter would emit a warning by default so why<br>
bother adding support for a brand new syntax which we already know it<br>
would be discouraged anyway?<br>
<br>
9) It goes against half of the Python Zen.<br>
<br>
-- <br>
Giampaolo - <a href="http://grodola.blogspot.com" rel="noreferrer" target="_blank">http://grodola.blogspot.com</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="m_615607781211211532m_1387460931039152909gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Giampaolo - <a href="http://grodola.blogspot.com" target="_blank">http://grodola.blogspot.com</a></div><div><br></div></div></div>