An "Object" class?
Alan Bawden
alan at csail.mit.edu
Wed Aug 28 23:53:00 EDT 2019
Cristian Cocos <cristi at ieee.org> writes:
> Thank you! I can see that the taxonomy of built-in classes (i.e. the
> subclass/superclass relations) is not very developed. At the very least I
> would have loved to see stuff such as int declared as a subClass/subType
> of float and the like--that is, a class taxonomy in tune with standard
> mathematical practice, but I am guessing that mathematical kosher-ness had
> to take a back seat to implementational concerns.
Except that numbers of type `int' are _not_ a subset of numbers of
type `float'! Some ints are much larger that the largest float.
In fact, both `int' and `float' are subclasses of `numbers.Real'. While it
is true that `numbers.Real' does not appear in the list returned by
`type.mro(int)', nevertheless `issubclass(int, numbers.Real)' and
`isinstance(2, numbers.Real)' are true. `type.mro' tells you something
about the _implementation_ of `int' and `float' that you _usually_ shouldn't
concern yourself with. Stick to `isinstance' and `issubclass' and
everthing looks pretty kosher.
--
Alan Bawden
More information about the Python-list
mailing list