Sorry, missed this part: On Oct 13, 2019, at 22:54, Chris Angelico <ros...@gmail.com> wrote:
>>>> isinstance(1, numbers.Complex) > True > > Explain the difference? `Complex` is an abstract type that defines an interface, which is loosely: supporting all the complex-arithmetic operators, properties like `real`, and methods like `conjugate`. Because `int` supports that interface, `int` is a subtype of `Complex`. The numeric-tower ABCs don’t have the same purpose as the concrete number types, or we wouldn’t need them in the first place. So it shouldn’t be surprising that they don’t have the same subtype relations. If you’re asking which set of relations is “mathematically correct”, then it depends on the context. Obviously the set of all Python `int` objects is a subset of the set of all possible things that meet the `Complex` interface, but that doesn’t mean they’re complex numbers, much less that they’re instances of `complex`. If you’re wondering whether integers are something you could define the laws of complex algebra over, then no, it isn’t. For example, one of the laws is that every number besides 0 has a multiplicative inverse, which obviously isn’t true for the set of integers. Or for the set of Python `int` values. But that’s not what the ABC is testing for, so that’s fine. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4BBAX2BEUZS7JD2BSXMRNGIPLOBLHFYL/ Code of Conduct: http://python.org/psf/codeofconduct/