[Python-ideas] PEP 505 (None coalescing operators) thoughts
Carl Meyer
carl at oddbird.net
Mon Sep 28 19:38:03 CEST 2015
On 09/28/2015 11:29 AM, Guido van Rossum wrote:
> On Mon, Sep 28, 2015 at 9:02 AM, Jeff Hardy <jdhardy at gmail.com
> <mailto:jdhardy at gmail.com>> wrote:
>
> -1 on the propagating member-access or index operators
>
>
> Can someone explain with examples what this refers to?
"Member-access or index operators" refers to the proposed ?. or ?[
operators.
"Propagating" refers to the proposed behavior where use of ?. or ?[
"propagates" through the following chain of operations. For example:
x = foo?.bar.spam.eggs
Where both `.spam` and `.eggs` would behave like `?.spam` and `?.eggs`
(propagating None rather than raising AttributeError), simply because a
`.?` had occurred earlier in the chain. So the above behaves differently
from:
temp = foo?.bar
x = temp.spam.eggs
Which raises questions about whether the propagation escapes
parentheses, too:
x = (foo?.bar).spam.eggs
Carl
-------------- 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/0b319962/attachment.sig>
More information about the Python-ideas
mailing list