<div dir="ltr">What about re-using try? Crystal does this (<a href="http://play.crystal-lang.org/#/r/gf5">http://play.crystal-lang.org/#/r/gf5</a>):<div><br></div><div><div>v = "ABC"</div><div>puts nil == v.try &.downcase # prints true</div><div>v = nil</div><div>puts nil == v.try &.downcase # prints false</div></div><div><br></div><div>Python could use something like:</div><div><br></div><div>v = 'ABC'</div><div>print(v try.downcase is None) # prints False</div><div>v = None</div><div>print(v try.downcase is None) # prints True</div><div><br></div><div>(Of course, the syntax would be a little less...weird!)</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 21, 2015 at 10:40 AM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Just to cut this thread short, I'm going to reject PEP 505, because ? is just too ugly to add to Python IMO. Sorry.<br><br></div><div class="gmail_extra">I commend Mark for his clean write-up, without being distracted, giving some good use cases. I also like that he focused on a minimal addition to the language and didn't get distracted by hyper-generalizations. <br><br>I also like that he left out f?(...) -- the use case is much weaker; usually it's the object whose method you're calling that might be None, as in title?.upper().<br><br></div><div class="gmail_extra">Some nits for the PEP:<br><br></div><div class="gmail_extra">- I don't think it ever gives the priority for the ?? operator. What would "a ?? b or c" mean?<br></div><div class="gmail_extra">- You don't explain why it's x ?? y but x ?= y. I would have expected either x ? y or x ??= y.<br></div><div class="gmail_extra">- You don't explain or show how far ?. reaches; I assume x?y.z is equivalent to None if x is None else x.y.z, so you don't have to write x?.y?.z just to handle x.y.z if x is None.<br></div><div class="gmail_extra">- The specification section is empty.<br></div><span class=""><div class="gmail_extra"><br>-- <br><div>--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></span></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Ryan</div><div dir="ltr">[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.<br></div><div dir="ltr"><div><a href="http://kirbyfan64.github.io/" target="_blank">http://kirbyfan64.github.io/</a><div style="display:inline-block;width:16px;height:16px"> </div></div></div></div></div></div></div></div>
</div>