True == 1 weirdness

Steven D'Aprano steve at pearwood.info
Thu Sep 17 03:22:19 CEST 2015


On Thu, 17 Sep 2015 03:41 am, Sven R. Kunze wrote:

> On 16.09.2015 19: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.
>>
>> And with operator overloading, < <=  > and => could have any meaning you
>> like:
>>
>> graph = a => b => c <= d <= e
>>
> 
> Sorry? What are you trying to do here?

Anything you like, I just made it up. That's the point: if a, b, etc have
overloaded the operators, they could mean anything. The idea I vaguely had
was that they constructed a graph, using => and <= as "arrows" so that the
above would be equivalent to the graph:

    a -> b -> c <- d <- e

(a to b, b to c; e to d, d also to c)


-- 
Steven



More information about the Python-list mailing list