[Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR
Aliaksei Yaletski
a.eletsky at gmail.com
Fri Jul 20 02:52:14 EDT 2018
Hi
I'm new to that list, hope, that my idea will be helpfull.
hi = hi OR len(a)
> ---
> where (A OR B) returns A if A is not None, otherwise it returns B.
>
Probably, we can introduce syntactic sugar for "if not equal" comparison?
Not only for "is not None" check, but for comparison with any expression.
Something like:
x = foo if 'value': bar
equal to :
x = foo if foo != 'value' else bar
so, expression:
x = foo if foo is not None else bar
become:
x = foo if None: bar
That syntax does not use new keywords or operators, looks pythonic and
simplify most common "is not None" expression.
--
Regards,
Aliaksei Yaletski.
Homepage: http://tiendil.org
Skype: Tiendil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180720/0e227da0/attachment.html>
More information about the Python-ideas
mailing list