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

Eric Fahlgren ericfahlgren at gmail.com
Thu Aug 2 19:01:04 EDT 2018


On Thu, Aug 2, 2018 at 3:39 PM MRAB <python at mrabarnett.plus.com> wrote:

> In the relevant code, is policy.mangle_from_ ever None?
>

That's impossible to know, since the initializer where this code originally
appears puts no constraints on the value of 'policy', it's just assumed to
have a 'mangle_from_' member...  I would be paranoid and assume, yes, it
can take on a value of None as there's nothing to indicate that it can't.

class Generator:
...
    def __init__(self, outfp, mangle_from_=None, maxheaderlen=None, *,
                 policy=None):
...
        if mangle_from_ is None:
            mangle_from_ = True if policy is None else policy.mangle_from_
        self._fp = outfp
        self._mangle_from_ = mangle_from_
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180802/c49fee60/attachment.html>


More information about the Python-ideas mailing list