A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-April/034649.html below:

[Python-Dev] Re: Re: lists v. tuples

[Python-Dev] Re: Re: lists v. tuplesAndrew Koenig ark@research.att.com
Tue, 15 Apr 2003 20:41:31 -0400 (EDT)
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.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4