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

Random832 random832 at fastmail.com
Thu Oct 1 20:50:07 CEST 2015


On Thu, Oct 1, 2015, at 14:36, MRAB wrote:
> It's _not_ guaranteed that there'll be an exception if a is None; None
> does have _some_ attributes.

Well, it hasn't got a "d" attribute, but point taken. However, wanting
to build expressions like this that will sometimes operate on the
attributes of None and other times operate on the attributes of the
non-None object normally expected to be present seems like an
*extremely* obscure thing to want.

> '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.

It doesn't escape being mixed with a different kind of expression, which
is sometimes accomplished with parentheses, but that's not really the
same thing.


More information about the Python-ideas mailing list