python3优劣_Python3 中的比较问题

最近看到 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

可能有点钻牛角尖了,请各位大神能指点一二,谢谢了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值