[Python-Dev] Changing semantics of issubclass when accepting atuple (original) (raw)
Guido van Rossum guido at python.org
Mon Dec 15 00:59:57 EST 2003
- Previous message: [Python-Dev] Changing semantics of issubclass when accepting atuple
- Next message: [Python-Dev] Changing semantics of issubclass when accepting atuple
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The same effect could be achieved by defining a class...
class myfavouritetypes(float, complex): pass if isinstance(x, (int, long, myfavouritetypes)): ...
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/)
- Previous message: [Python-Dev] Changing semantics of issubclass when accepting atuple
- Next message: [Python-Dev] Changing semantics of issubclass when accepting atuple
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]