checking if two things do not equal None

Chris Angelico rosuav at gmail.com
Sun Mar 30 03:36:49 EDT 2014


On Sun, Mar 30, 2014 at 5:52 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>
>> The problem isn't that I can't see what the comparisons are. It makes
>> very good sense to bound a variable within constants; but you already
>> know exactly where 2 is on the number line, so asking "Is 2 between
>> these two variables" seems a bit odd. Maybe it's less so with the
>> strong mathematical background, but it seems odd to me.
>
> I don't feel odd about asking the question “Is 2 between these two
> values?”. It's straightforward and concise. Can you explain better why
> you find it odd?

Possibly because the "variable between two constants" is something
I've done often (usually in the more explicit form of "x > min && x <
max" in a language without chained comparisons), usually
bounds-checking some value. I've never had to ask whether a single
constant has two variables, one on either side. But that's just that
I've personally never done it; it doesn't mean nobody does it, by any
means.

ChrisA



More information about the Python-list mailing list