Python 自定义一个正无穷大的整数

发布时间:2022-06-27 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Python 自定义一个正无穷大的整数脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
 1 作者:0x76
 2 链接:https://www.zhihu.COM/question/429361837/answer/1565316314
 3 知乎 5 
 6 class inf(int):
 7     '''
 8         InfinITe positive integer
 9     '''
10     def __init__(self):
11         pass
12 
13     def __str__(self):
14         return 'inf_int'
15 
16     def __float__(self) -> float:
17         return float('inf')
18 
19     def __eq__(self, rhs) -> bool:
20         return False
21     def __ne__(self, rhs) -> bool:
22         return True
23     def __lt__(self, rhs) -> bool:
24         return False
25     def __le__(self, rhs) -> bool:
26         return False
27     def __gt__(self, rhs) -> bool:
28         return True
29     def __ge__(self, rhs) -> bool:
30         return True

 

脚本宝典总结

以上是脚本宝典为你收集整理的Python 自定义一个正无穷大的整数全部内容,希望文章能够帮你解决Python 自定义一个正无穷大的整数所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。