[Python-ideas] Null coalescing operators

Terry Reedy tjreedy at udel.edu
Mon Sep 21 22:44:18 CEST 2015

On 9/21/2015 11:28 AM, Ron Adam wrote:

> We could add a "not None" specific boolean operators just by appending !
> to them.
>      while! x:    <-->   while x != None:
>      if! x:       <-->   if x != None:
>      a or! b      <-->   b if a != None else a
>      a and! b     <-->   a if a != None else b
>      not! x       <-->   x if x != None else None

'!= None' should be 'is not None' in all examples. Since  'is not None' 
is a property of the object, so I think any abbreviation should be 
applied to the object, not the operator.  "while x!", etcetera

Terry Jan Reedy

More information about the Python-ideas mailing list