<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 28, 2015 at 12:53 PM, Carl Meyer <span dir="ltr"><<a href="mailto:carl@oddbird.net" target="_blank">carl@oddbird.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 09/28/2015 01:43 PM, Carl Meyer wrote:<br>
[snip]<br>
<span class="">> I assume that the short-circuiting would follow the precedence<br>
> order; that is, nothing with looser precedence than member and index<br>
> access would be short-circuited. So, for example,<br>
><br>
> foo?.bar['baz'].spam<br>
><br>
> would short-circuit the indexing and the final member access, translating to<br>
><br>
> foo.bar['baz'].spam if foo is not None else None<br>
><br>
> but<br>
><br>
> foo?.bar or 'baz'<br>
><br>
> would mean<br>
><br>
> (foo.bar if foo is not None else None) or 'baz'<br>
><br>
> and would never evaluate to None. Similarly for any operator that binds<br>
> less tightly than member/index access (which is basically all Python<br>
> operators).<br>
<br>
</span>For a possibly less-intuitive example of this principle (arbitrarily<br>
picking the operator that binds next-most-tightly), what should<br>
<br>
foo?.bar**3<br>
<br>
mean?<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">It's nonsense -- it means (foo?.bar)**3 but since foo?.bar can return None and None**3 is an error you shouldn't do that. But don't try to then come up with syntax that rejects foo?.bar**something statically, because something might be an object implements __rpow__.<br><br></div><div class="gmail_extra">And I still don't see why this "principle" would be important.<br clear="all"></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>