True == 1 weirdness

Random832 random832 at fastmail.com
Wed Sep 16 19:47:15 CEST 2015


On Wed, Sep 16, 2015, at 13:33, Steven D'Aprano wrote:
> 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.

But they won't return *true* unless they're the same or similar types.

> And with operator overloading, < <=  > and => could have any meaning you
> like:
> 
> graph = a => b => c <= d <= e

Are you suggesting that all objects concerned are a magical "graph node
object", the <= and [sic] => operators of which return "edge objects",
the and operator of which constructs a graph object containing all such
edges? That's *horrifying*. And won't actually work. We haven't actually
got an => operator, thankfully, and you can't overload 'and'.

I bet you could do it in C++ though.


More information about the Python-list mailing list