[Python-ideas] PEP 505 (None coalescing operators) thoughts
Sven R. Kunze
srkunze at mail.de
Mon Sep 28 18:11:45 CEST 2015
On 28.09.2015 18:02, Jeff Hardy wrote:
> +1 for the idea
> -1 on the propagating member-access or index operators
> +1 on spelling it "or?"
> C# has had null-coalescing since about 2005, and it's one feature I
> miss in every other language that I use. I view null/None as a
> necessary evil, so getting rid of them as soon possible is a good
> thing in my book. Nearly every bit of Python I've ever written would
> have benefitted from it, if just to get rid of the "x if x is not None
> else " mess.
> That said, I think the other (propagating) operators are a mistake,
> and I think they were a mistake in C# as well. I'm not I've ever had a
> situation where I wished they existed, in any language. Better to get
> rid of the Nones as soon as possible than bring them along. It's worth
> reading the C# design team's notes and subsequent discussion on the
> associativity of "?."  since it goes around and around with no
> really good answer and no particularly intuitive behaviour.
> Rather than worry about that, I'd prefer to see just the basic
> None-coalescing added. I like Alessio's suggestion of "or?" (which
> seems like it should be read in a calm but threatening tone, a la Liam
> Neeson). It just seems more Pythonic; ?? is fine in C# but seems
> punctuation-heavy for Python. It does mean the ?= and ?. and ? are
> probably out, and I'm OK with that.
> - Jeff
>  https://roslyn.codeplex.com/discussions/543895
That sums it all up for me as well, though I would rather use "else"
instead of "or?" (see punctuation-heavy).
More information about the Python-ideas