[Python-ideas] PEP 572: Assignment Expressions (post #4)

Ethan Furman ethan at stoneleaf.us
Fri Apr 13 02:27:11 EDT 2018


On 04/12/2018 09:52 PM, Chris Angelico wrote:

> foo := a > b   # does this capture 'a', or 'a > b'?
> bar := c + d   # 'c' or 'c + d'?
>
> I'm open to argument here, but my thinking is that these should
> capture 'a' and 'c + d'.

I think := should act the same as = or there will be plenty of confusion.  If one wants to capture less then parenthesis 
can be used to narrow it down:

   (foo := a) > b

Looked at another way -- you already have the value named as 'a', so why would you also name it as 'foo'?

--
~Ethan~


More information about the Python-ideas mailing list