<div dir="ltr"><div class="gmail_extra">><span style="font-family:sans-serif"> None if var:= function() is None else var.</span><span style="font-family:sans-serif">method() </span>
<br><br></div><div class="gmail_extra">Make sense.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">In some specific scenes(maybe general, I'm not sure),<br> <br></div><div class="gmail_extra"> var.method() if var:=function() else var<br><br></div><div class="gmail_extra">looks cool although it's not really null checking. It works for Python, just like use `if lst` to check if the list `lst` is empty.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-13 11:22 GMT+08:00 David Mertz <span dir="ltr"><<a href="mailto:mertz@gnosis.cx" target="_blank">mertz@gnosis.cx</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Yes, I should have added ternary expressions to if statements. I can definitely see the use there.</div><div dir="auto"><br></div><div dir="auto">However, your example is not null checking. You'd have to modify it slightly to get that:</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">None if var:= function() is None else var.</span><span style="font-family:sans-serif">method() </span></div><div dir="auto"><font face="sans-serif"><br></font></div><div dir="auto"><font face="sans-serif">Still not bad looking.<br></font><br><div class="gmail_quote" dir="auto"><div><div class="h5"><div dir="ltr">On Thu, Apr 12, 2018, 11:01 PM Thautwarm Zhao <<a href="mailto:yaoxiansamma@gmail.com" target="_blank">yaoxiansamma@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><br><div class="gmail_extra">
> You're looking at a very early commit there. I suggest looking at the<br>> most recent commits on one of two branches:<br><br>
<a href="https://github.com/Rosuav/cpython/blob/statement-local-variables/Grammar/Grammar" rel="noreferrer noreferrer" target="_blank">https://github.com/Rosuav/<wbr>cpython/blob/statement-local-<wbr>variables/Grammar/Grammar</a><br>
<a href="https://github.com/Rosuav/cpython/blob/assignment-expressions/Grammar/Grammar" rel="noreferrer noreferrer" target="_blank">https://github.com/Rosuav/<wbr>cpython/blob/assignment-<wbr>expressions/Grammar/Grammar</a><br>
<br>
> Those are the two most recent states in my progress towards (a)<br>
> statement-local name bindings with "EXPR as NAME", and (b) assignment<br>
> expressions with "target := value".
<br><br></div><div class="gmail_extra">Okay, and the syntax "target := value" seems to be much easier to handle with. <br><br></div><div class="gmail_extra">I do support this feature, but now I'm worried about the meaning of ':=', it seems to be a lazy assignment in some degree. I'm not sure using ':=' is proper here.<br><br><br>>
Inasmuch as I might like assignment expressions, it would only be in while or if statements, personally.
<br><br></div><div class="gmail_extra">Not exactly, assignment expression also works for "if expression", we can now have null checking.<br><br></div><div class="gmail_extra"> var.method() if var:= function() else None<br><br></div><div class="gmail_extra">Null checking is importance enough to have a specific syntax in many other languages(C#, kotlin, Ruby and so on), and we can even have more than null checking by adding expression assignment.<br><br></div><div class="gmail_extra"><br><br></div><div class="gmail_extra"><br></div></div></div></div><span class="">
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" rel="noreferrer" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br></span>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</blockquote></div></div></div>
</blockquote></div><br></div></div>