[Python-Dev] Changing semantics of issubclass when accepting atuple

Guido van Rossum guido at python.org
Mon Dec 15 00:59:57 EST 2003

> The same effect could be achieved by defining a class...
>   class my_favourite_types(float, complex):
>     pass
>   if isinstance(x, (int, long, my_favourite_types)):
>     ...

I hope you forgot the smiley, as this would otherwise have to be
explained as a typical "before the first coffee" lapse. :)

First of all, you can't multiply inherit from built-in classes.  But
even if you could, it would be wrong: while an instance of
my_favourite_types would indeed be an instance of float,
3.14 is not an instance of my_favourite_types!  You'd need
my_favourite_types to be a common base class of float and complex for
the test to work the way you want it.

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

More information about the Python-Dev mailing list