[Python-ideas] Null coalescing operators
python at lucidity.plus.com
Sat Sep 19 01:18:38 CEST 2015
Apologies for the self-reply. I just wanted to clarify a couple of things.
On 18/09/15 23:56, Erik wrote:
> If the foo operator uses the magic method "__foo__" to mean "return an
> object to be used in place of the operand should it be considered ...
> false? [or some other definition - I'm not sure]"
Not "false", I think. The "foo" operator is meant to mean "I will go on
to use the resulting object in any way imaginable and it must cope with
that and return a value from any attempts to use it that will generally
mean 'no'" (*).
> If that was a postfix operator which has a high precedence, then:
> bar = foo?
> and the original syntax suggestion:
> bar = foo?.isoformat()
Which is clearly wrong - the first part should be:
baz = foo?
bar = baz.isoformat()
(*) Should we call the operator "shrug"?
More information about the Python-ideas