[Python-ideas] Null coalescing operators

MRAB python at mrabarnett.plus.com
Sat Sep 19 02:01:50 CEST 2015


On 2015-09-19 00:44, Sven R. Kunze wrote:
>
>
> On 19.09.2015 01:18, Erik wrote:
>> 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?
>>> bar.isoformat()
>>>
>>> and the original syntax suggestion:
>>>
>>> bar = foo?.isoformat()
>>
>> Which is clearly wrong - the first part should be:
>>
>> baz = foo?
>> bar = baz.isoformat()
>>
>> E.
>>
>> (*) Should we call the operator "shrug"?
>
> Maybe monad?
>
Too fancy.

How about "ni"? :-)



More information about the Python-ideas mailing list