> 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/)
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