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

Chris Angelico rosuav at gmail.com
Tue Jul 24 03:30:18 EDT 2018


On Tue, Jul 24, 2018 at 5:26 PM, Brice Parent <contact at brice.xyz> wrote:
> Le 24/07/2018 à 00:39, Chris Angelico a écrit :
>>
>> On Tue, Jul 24, 2018 at 8:22 AM, Thomas Jollans <tjol at tjol.eu> wrote:
>
> ...
>>
>> What about:
>>
>> 5 < x < 10
>>
>> Can you add parentheses to that to "make precedence and evaluation order
>> clear"?
>
> Correct me if I'm wrong, but to my knowledge, this is just a shorthand to `5
> < x and x < 10`.

Not quite; the chained form will evaluate 'x' only once. It's broadly
the same, but not identical.

ChrisA


More information about the Python-ideas mailing list