[Python-ideas] Null coalescing operators

Sven R. Kunze srkunze at mail.de
Sat Sep 19 21:09:48 CEST 2015


On 19.09.2015 14:48, Stephen J. Turnbull wrote:
> Sven R. Kunze writes:
>
>   > Issue is, None is so convenient to work with. You only find out the
>   > code smell when you discover a "NoneType object does not have
>   > attribute X"
>
> That's exactly what should happen (analogous to a "signalling NaN").

Not my point, Stephen. My point is, you better avoid None (despite its 
convenience) because you are going to have a hard time finding its 
origin later in the control flow.

Question still stands: is None really necessary to justify the 
introduction of convenience operators like "?." etc.?

> The problem is if you are using None as a proxy for a NULL in another
> subsystem that has "NULL contagion" (I prefer that to "coalescing").

How would you solve instead?


Best,
Sven


More information about the Python-ideas mailing list