[Python-3000] Need help completing ABC pep

Guido van Rossum guido at python.org
Sat Apr 21 17:06:37 CEST 2007

On 4/21/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 12:33 PM 4/20/2007 -0700, Talin wrote:
> >Additionally, the need to override the classification of an
> >object can be done more cleanly using generic functions: In the simplest
> >case, one can define a "category membership" generic function that
> >simply returns False in the base implementation, and then provide
> >overrides that return True for any classes of interest.
> Yes, but that's sort of like saying it's better to point a pistol at your
> foot than a shotgun.  :)  Explicitly testing category membership is a bug,
> not a feature; you're far better off defining an overload to do whatever it
> was you were going to make the if-then test do.

I don't believe that's always true. I can imagine use cases where, if
I were writing it in an if-then-else fashion, I'd be writing the
*same* if-test several times as part of a particular algorithm,
without having an easy way to refactor the algorithm so that there's
only one place testing it. Turning each place where the if-test is
repeated into a different GF might be a wasted of time; turning just
the test into a GF seems just right. (IN THAT PARTICULAR CASE.)

Note that I don't object against the idea that usually a GF is better;
I just don't think it always is so.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list