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

Guido van Rossum guido at python.org
Thu Apr 12 23:27:36 EDT 2018


On Thu, Apr 12, 2018 at 8:22 PM, David Mertz <mertz at gnosis.cx> wrote:

> Yes, I should have added ternary expressions to if statements. I can
> definitely see the use there.
>
> However, your example is not null checking. You'd have to modify it
> slightly to get that:
>
> None if var:= function() is None else var.method()
>
> Still not bad looking.
>

Though a long way from function()?.method() per PEP 505. :-)

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180412/1d516427/attachment.html>


More information about the Python-ideas mailing list