[Python-Dev] Re: Re: lists v. tuples
Guido van Rossum
Wed, 16 Apr 2003 09:30:37 -0400
> Guido> That's cute, but a bit too magical for my taste... It's not
> Guido> immediately obvious how this would be done (I know how, but it
> Guido> would require a lot of explaining). Plus, -1 is a perfectly
> Guido> valid truth value.
> Yes, I know that -1 is a valid truth value.
> Here's the trick. The object of the game is to figure out whether
> f is < or __cmp__.
> Suppose you call f(x, y) and it returns 0. Then you don't care
> which one f is, because x<y is false either way.
> So the first time you care is the first time f(x, y) returns nonzero.
> Now you can find out what kind of function f is by calling f(y, x).
> If f(y, x) returns zero, f is <. Otherwise, it's a 3-way comparison.
Right. There's no flaw in this logic, but I'd hate to have to explain
it over and over... I don't want people to believe that Python can
somehow magically sniff the difference between two functions; they
might expect it in other contexts.
--Guido van Rossum (home page: http://www.python.org/~guido/)