[Python-ideas] PEP 505: None-aware operators

Chris Angelico rosuav at gmail.com
Wed Aug 1 04:49:30 EDT 2018


On Wed, Aug 1, 2018 at 6:45 PM, Jonathan Fine <jfine2358 at gmail.com> wrote:
> Hi Chris
>
> Thank you for your reply. I think we're making good progress.
>
> You wrote
>
>>> 10) a ?. b ?. c
>>> 11) (a ?. b) ?. c
>>
>> I would parse those differently, but you may be right that they'll
>> always have the same final result.
>
> I'd like to get some certainty on this. I'm not aware of any value of
> 'a' for which #10 and #11 give different values. Can you (or anyone
> else) think of any such value?
>
>> Technically they should result in different code, though.
>
> Maybe. We need to think. Should can be a difficult word. Elsewhere you
> have, as I recall, pointed out that
>     if None:
>         do_something()
> generates no code.
>
> Perhaps the compiler should collapse #11 to #10, if they are
> equivalent. But this is a side issue.
>
> So, are there any values of 'a' for which #10 and #11 don't give the
> same result?

I'm not prepared to put my neck out and say "They are absolutely
identical" and have people jump on me with some technicality. What is
your point here?

ChrisA


More information about the Python-ideas mailing list