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

Random832 random832 at fastmail.com
Thu Oct 1 06:19:08 CEST 2015


Andrew Barnert via Python-ideas
<python-ideas at python.org> writes:

> On Sep 30, 2015, at 18:08, MRAB <python at mrabarnett.plus.com> wrote:
>> 
>> It's only just occurred to me that there's a small inconsistency here.
>> The "?.", "?[" and "?(" will short-circuit on None, whereas the "??"
>> will short-circuit on non-None.
>> 
>> Would that cause any confusion in practice?
>
> I noticed this when I was trying to write out grammar, sample ASTs,
> and sample bytecode for these things. I went searching the thread and
> saw no one had pointed it out. I went through docs and blogs for other
> languages, and didn't see anyone pointing out, complaining about, or
> offering to clear up any confusion. So I figured I wouldn't mention
> it, and see if anyone else even noticed.

How is it worse than the fact that and short-circuits on true whereas or
short-circuits on false? Short-circuiting logically applies to the case
that *can* be short-circuited.

For the AST issue, I'm curious as to what you ended up doing about the
whole-atom_expr nature of the short-circuiting and the fact that ASTs
don't currently represent an atom_expr as a single object containing a
list of subscript/attribute/call items?



More information about the Python-ideas mailing list