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

Andrew Barnert abarnert at yahoo.com
Thu Oct 1 04:39:13 CEST 2015


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.

The fact that an experienced programmer like you didn't even notice it until after a zillion messages over a span of weeks, and apparently nobody else did at all, seems to imply that there's no dangerously misleading intuitive parallel here.

(By the way, I have a feeling that including ?= will increase the risk of confusion, but I have no idea where that feeling comes from, so it may just be random noise in my head, maybe because I like ?. but don't particularly like ?= or something...)


More information about the Python-ideas mailing list