Function to take the minimum of 3 numbers

Chris Angelico rosuav at gmail.com
Sun Oct 9 21:36:16 EDT 2016


On Mon, Oct 10, 2016 at 11:38 AM, Matt Wheeler <funkyhat at gmail.com> wrote:
> On Mon, 10 Oct 2016, 00:56 Ian Kelly, <ian.g.kelly at gmail.com> wrote:
>
>> On Oct 9, 2016 2:57 PM, <breamoreboy at gmail.com> wrote:
>> The Pythonic way
>>
>> if b >= a <= c:
>>     ...
>>
>>
>> Better:
>>
>> if a <= b <= c:
>>     ...
>>
>
> That's not equivalent. Consider `a, b, c = 1, 7, 4`
>
>
>> Using consistent operators is not required but is easier to read and less
>> confusing.
>>
>
> Unfortunately in this case it's also less correct

Proof that it's confusing: Someone tried to tidy up the code, and
unwittingly changed its semantics.

ChrisA



More information about the Python-list mailing list