[Python-ideas] Null coalescing operator
Pavol Lisy
pavol.lisy at gmail.com
Wed Nov 2 18:59:41 EDT 2016
On 10/15/16, Nick Coghlan <ncoghlan at gmail.com> wrote:
> * None-coalescing operator: x ?or y
> * None-severing operator: x ?and y
> * None-coalescing augmented assignment: x ?= y
> * None-severing attribute access: x?.attr
> * None-severing subscript lookup: x?[expr]
Please don't be too harsh to me for my next words! :)
Just to trying to find something more cool (at least for young people
:P ) I was thinking about emoticons...
:( (means I am not happy because left is None)
But parenthesis would be too confusing with "real" parenthesis.
Example: (x :( (a + b)) # and editor would have problem to find
corresponding pairs of parenthesis!
So I am just trying to replace parenthesis with <> and playing with it
* None-coalescing operator: x :< y
* None-severing operator: x :> y
* None-coalescing augmented assignment: x =< y
* None-severing attribute access: x.>attr
* None-severing subscript lookup: x[>expr] # ok this one seems a
little weird to me too
alternatively: x:>[expr]
With this syntax/paradigm we could have also:
* None-severing augmented assignment: x => y
About spelling: we could say None-coalescing and None-severing
operator in theory and sad and happy operator in real life. :)
PL.
More information about the Python-ideas
mailing list