最近看到 Python 官方文档时,在标准库中的内置类型的比较部分卡住了,有一段感觉不是很明白,摘抄如下:
Objects of different types, except different numeric types, never compare equal. Furthermore, some types (for example, function objects) support only a degenerate notion of comparison where any two objects of that type are unequal. The <, <=, > and >= operators will raise a TypeError exception when comparing a complex number with another built-in numeric type, when the objects are of different types that cannot be compared, or in other cases where there is no defined ordering
原文在 https://docs.python.org/3/library/stdtypes.html#comparisons 那个表格的下面那一段,主要是那一句:Furthermore, some types (for example, function objects) support only a degenerate notion of comparison where any two objects of that type are unequal.
这个degenerate notion of comparison是什么?字面理解的话好像是退化的比较概念,或者说是简化版的比较,这个指的是什么?
已知的是:Python3 中不同类型的比较好像只有不同的数字类型能比较,而且复数也不能和其他的数字类型比较,其他的不同类型之间好像只能用"==","!=","is","is not"比较。
Python2 中不同类型好像根据 id 来比较的,参考: Stack Overflow
可能有点钻牛角尖了,请各位大神能指点一二,谢谢了。