[Python-ideas] PEP 505 (None coalescing operators) thoughts

Carl Meyer carl at oddbird.net
Mon Sep 28 21:53:05 CEST 2015

On 09/28/2015 01:43 PM, Carl Meyer wrote:
> 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




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150928/927b0959/attachment.sig>

More information about the Python-ideas mailing list