[Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

Eric Fahlgren ericfahlgren at gmail.com
Thu Aug 2 15:03:34 EDT 2018


>From the PEP:
>
>From email/generator.py (and importantly note that there is no way to
substitute or for ?? in this situation):
>
mangle_from_ = True if policy is None else policy.mangle_from_
> After updating:
>
mangle_from_ =
policy?.mangle_from_ ?? True

I cannot see how these are equivalent, and cannot understand what the
cryptic comment means.

>>> policy.mangle_from_ = None
>>>
True if policy is None else policy.mangle_from_
None

>>>
policy?.mangle_from_ ?? True
True (??? since lhs is None?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180802/c69b4ba7/attachment.html>


More information about the Python-ideas mailing list