Is this valid ?
John Machin
sjmachin at lexicon.net
Wed Mar 19 17:51:15 EDT 2008
On Mar 20, 8:18 am, Stef Mientki <stef.mien... at gmail.com> wrote:
> hello,
>
> by accident I typed a double value test,
> and to my surprise it seems to work.
> Is this valid ?
>
> a = 2
> b = 2
>
> a == b == 2
>
Of course. You can chain comparisons as much as you like and is
(semi-)sensible, e.g.
assert 0 < thing_index < thing_count <= UTTER_MAX_NTHINGS
There was an interesting use of chained comparison within the last day
or 2 in a thread about deriving a set of duplicated list elements --
look for subject == "finding items that occur more than once in a
list" and author == "Arnaud Delobelle".
Cheers,
John
More information about the Python-list
mailing list