[Python-ideas] Fwd: Null coalescing operator
Random832
random832 at fastmail.com
Sat Sep 10 22:36:20 EDT 2016
On Sat, Sep 10, 2016, at 19:38, David Mertz wrote:
> x2 = x?.foo
>
> x3 = x?.bar?.baz?[x2]
A. if you're doing three different things with x, why are you using this
instead of wrapping it in an if statement?
B. Under some of the proposals, unless x.bar might be None independently
of x not being None, this would just be "x?.bar.baz[x2]
> x4 = x?(x?.val)
C. Under some of the proposals, the inner contents of the call brackets
aren't evaluated if x is None, so you don't need to use x?.val here.
> result = x3?(x4)
More information about the Python-ideas
mailing list