最近,我阅读了“流利的python”,理解了==操作符如何使用python对象,并使用了__eq__()方法。但是它如何与int实例在python2中工作呢?__eq__(b) File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__eq<
下面的代码在Python3 (3.5.2)中运行良好,但在Python2中引发了一个AttributeError: 'super' object has no attribute '__eq__' (2.7.12) return super(Derived, self).__eq__(other)
a, b = Derived(1024), Der
我实现了一个类和它的元类,这两个类都定义了包括__eq__和__hash__在内的二进制dunder方法。元类的__eq__方法应该简单地实例化该类,然后将比较结果传递给类运算符。/test.py", line 14, in __eq__ File "/usr/lib/python3.6/abc.py",/test.py", line 14, in _