[Python-ideas] Null coalescing operators
Random832
random832 at fastmail.com
Sat Sep 19 08:55:13 CEST 2015
Guido van Rossum <guido at python.org> writes:
> Let me propose a (hyper?)generalization: it could be combined with any
> binary operation, e.g. "a?+b" would mean "None if a is None else a+b".
I'd have read it as "None if a is None or b is None else a+b". If you
want to only do it for one of the operands you should be explicit.
I'm not sure if I have a coherent argument for why this shouldn't apply
to ?[, though.
More information about the Python-ideas
mailing list