Re: [Python-ideas] [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

On Fri, Apr 27, 2018 at 04:24:35PM -0400, Wes Turner wrote:
if ((1) or (x := 3)): if ((y := func(x)) if x else (x := 3))
Wes, there is *absolutely nothing new* here. This sort of error is already possible in Python. Do you see a lot of code like: if (1 or sequence.append(3) or sequence[-1]): in real life? If you do, then I'm really, really sorry that you are forced to deal with such rubbish code, but honestly, the vast bulk of Python programmers do not write like that, and they won't write this either: if (1 or (x := 3)): [...]
The same applies to any operation at all. /sarcasm I guess adding print() to the language was a mistake, because we can write rubbish code like this: if 1 or print(x): and then be confused by the fact that x doesn't get printed. /end sarcasm In another post, you insisted that we need to warn in the PEP and the docs not to do this sort of thing. Should we also go through and add these warnings to list.append, dict.update, set.add, etc? I trust that the answer to that is obviously no. And neither do we have to assume that people who use binding-expressions will lose their minds and start writing the sort of awful code that they don't write with anything else. -- Steve

On Sat, Apr 28, 2018 at 10:37:33AM +1000, Steven D'Aprano wrote:
On Fri, Apr 27, 2018 at 04:24:35PM -0400, Wes Turner wrote: [...]
Oops, sent to the wrong list. Sorry for the noise. -- Steve

On Sat, Apr 28, 2018 at 10:37:33AM +1000, Steven D'Aprano wrote:
On Fri, Apr 27, 2018 at 04:24:35PM -0400, Wes Turner wrote: [...]
Oops, sent to the wrong list. Sorry for the noise. -- Steve
participants (1)
-
Steven D'Aprano