
On 09/28/2015 01:43 PM, Carl Meyer wrote: [snip]
I assume that the short-circuiting would follow the precedence order; that is, nothing with looser precedence than member and index access would be short-circuited. So, for example,
foo?.bar['baz'].spam
would short-circuit the indexing and the final member access, translating to
foo.bar['baz'].spam if foo is not None else None
but
foo?.bar or 'baz'
would mean
(foo.bar if foo is not None else None) or 'baz'
and would never evaluate to None. Similarly for any operator that binds less tightly than member/index access (which is basically all Python operators).
For a possibly less-intuitive example of this principle (arbitrarily picking the operator that binds next-most-tightly), what should foo?.bar**3 mean? Carl