[Python-Dev] Re: Re: lists v. tuples (original) (raw)
Andrew Koenig ark@research.att.com
Tue, 15 Apr 2003 20:41:31 -0400 (EDT)
- Previous message: [Python-Dev] Re: Re: lists v. tuples
- Next message: [Python-Dev] Re: Re: lists v. tuples
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: [Python-Dev] Re: Re: lists v. tuples
- Next message: [Python-Dev] Re: Re: lists v. tuples
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]