True == 1 weirdness

Steven D'Aprano steve at pearwood.info
Wed Sep 16 19:33:24 CEST 2015


On Thu, 17 Sep 2015 01:40 am, Random832 wrote:

> "in" suggests a relationship between objects of different types (X and
> "something that can contain X") - all the other comparison operators are
> meant to work on objects of the same or similar types.

`is` and the equality operators are intended to work on arbitrary objects,
as are their inverses `is not` and inequality.

And with operator overloading, < <=  > and => could have any meaning you
like:

graph = a => b => c <= d <= e


> Why not make isinstance a comparison operator and have "1 instanceof int
> instanceof type"? Having chaining apply to things that are not
> semantically comparisons is just baffling.

Somewhat ugly, I grant you, but if baffling? 



-- 
Steven



More information about the Python-list mailing list