在python中使用户定义的类可排序和/或可清除时,需要覆盖/实现哪些方法?
有什么值得注意的?
我输入dir({})我的解释器以获取内置dicts的方法列表.其中,我假设我需要实现一些子集
['__cmp__', '__eq__', '__ge__', '__gt__', '__hash__', '__le__', '__lt__', '__ne__']
Run Code Online (Sandbox Code Playgroud)
与Python2相比,Python3必须实现哪些方法有区别?