Check if a given value is out of certain range

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Oct 1 19:34:47 EDT 2015


On 01/10/2015 19:18, Steven D'Aprano wrote:
> On Thu, 1 Oct 2015 08:31 am, Mark Lawrence wrote:
>
>>> What is so "yuck" about that?  What would you do instead?  It seems like
>>> the best solution to me.  Easy to read, fast to execute.
>>>
>>
>> I have to parse those damn brackets and then figure out the inverted
>> logic. Give me x < 0 or x > 10 any day of the week.  When you're an old,
>> senile git like me, readability counts :-)
>
> With the greatest of respect Mark, I don't believe that for a second. Your
> sig line, which you have used without fail for more years than I can
> remember includes the phrase "ask not what our language can do for you". If
> you can understand that, I don't believe that you cannot figure out how to
> go from this:
>
> # x is within the range a to b
> a <= x < = b
>
> to this:
>
> # x is NOT within the range a to b
> not a <= x < = b
>
> You're certainly a senile old git if you think we're falling for that
> one :-)

Why do you think I never gamble at anything, it's a mug's game.

>
> P.S. in case you missed it, you don't actually need the params, since the
> precedence of not is lower than the other operators.

I confess that I did not bother to check.

>
> Did-I-include-sufficient-smileys-ly y'rs,
>

Not bad.  However after the big match coming up on Saturday evening UK 
time one of us will possibly be putting up ginormous quantities of 
smileys, matched by the ginormous quantity of grimaces from the other :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list