<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 21, 2015 at 3:45 PM, Terry Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 9/21/2015 5:48 PM, Guido van Rossum wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
On Mon, Sep 21, 2015 at 2:23 PM, Terry Reedy<br>
<<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a><br></span>
<mailto:<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>>> wrote:<br>
</blockquote><span class="">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  I agree with Paul Moore that propagating None is generally a bad<br>
  idea. It merely avoids the inevitable exception.<br>
</blockquote>
<br></span>
To me, this is the key idea in opposition to proposals that make propagating None easier.<span class=""><br></span></blockquote><div><br></div><div>(I didn't write that, you [Terry] did. It looks like our mailers don't understand each other's quoting conventions. :-( )<br></div><div>Â </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I don't think the big issue is bool(x) being too broad. That's what the<br>
binary ?? operator is trying to fix, but to me the more useful operators<br>
are x?.y and x?[y], both of which would still require repetition of the<br>
part on the left when spelled using ??.<br>
<br>
This is important when x is a more complex expression that is either<br>
expensive or has a side-effect. E.g. d.get(key)?.upper() would currently<br>
have to be spelled as (some variant of)<br>
</blockquote>Â Â Â Â
> "None if d.get(key) is None else d.get(key).upper()"<br>Â Â Â Â
> and the ?? operator doesn't really help for the<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
repetition -- it would still be "d.get(key) ?? d.get(key).upper()".<br>
<br>
In general to avoid this repetition you have to introduce a local<br>
variable, but that's often awkward and interrupts the programmer's<br>
"flow".<br>
</blockquote>
<br></span>
try:<br>
  x = d.get(key).upper()<br>
except AttributeError:<br>
  x = None<br>
<br>
is also a no-repeat equivalent when d.values are all strings. I agree than "x = d.get(key)?.upper()" is a plausible abbreviation. But I am much more likely to want "x = ''" or another exception as the alternative. I guess some other pythonistas like keeping None around more than I do ;-).<br clear="all"></blockquote></div><br></div><div class="gmail_extra">Eew. That try/except is not only very distracting and interrupts the flow of both the writer and the reader, it may also catch errors, e.g. what if the method being called raises an exception (not a problem with upper(), but definitely with user-defined methods).<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>