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

Steven D'Aprano steve at pearwood.info
Thu Oct 1 21:48:43 CEST 2015


On Thu, Oct 01, 2015 at 02:50:07PM -0400, Random832 wrote:
> On Thu, Oct 1, 2015, at 14:36, MRAB wrote:
[...]
> > 'and' and 'or' don't escape parentheses. I'd take it as a general rule
> > that short-circuiting doesn't escape parentheses.
> 
> Sure they do. In what way is (a and b) and c different from a and b and
> c? Heck, (a and b) and (c and d) even compiles to the same bytecode as
> other groupings [demonstrating it has the same actual semantics] *even
> though it is a different AST*. But even if it didn't, it would just be
> jumping to another jump opcode.

I don't see what this has to do with null aware attribute access.

If I wrote:

(spam?.eggs.cheese).__class__

the obvious intention is that it should evaluate like:

temp = spam?.eggs.cheese
temp.__class__


only without the use of a temporary name.



-- 
Steve


More information about the Python-ideas mailing list