Methods IronPython:instancemethod对象继承所属类的运算符重载
我在IronPython(2.7.5)中遇到了一个奇怪的现象。请查看以下示例代码:Methods IronPython:instancemethod对象继承所属类的运算符重载,methods,operator-overloading,ironpython,Methods,Operator Overloading,Ironpython,我在IronPython(2.7.5)中遇到了一个奇怪的现象。请查看以下示例代码: class X(object): def __eq__(self, other): print "__eq__" return False def foo(self): return 1 a = X() print a.foo == a.foo 使用IronPython运行时,输出为: __eq__ False 我不明白为什
class X(object):
def __eq__(self, other):
print "__eq__"
return False
def foo(self):
return 1
a = X()
print a.foo == a.foo
使用IronPython运行时,输出为:
__eq__
False
我不明白为什么要使用类X的相等运算符重载(a.foo的类型是instancemethod,而不是X)
使用CPython时,输出为
True
我猜这是IronPython中的一个bug。有人同意吗?对我来说,这看起来像一个bug,
IronPython
的行为应该像CPython
。是否要在GitHub
上打开一个问题?如果你没有账户,我会帮你做的。请让我知道。对不起,我没有GitHub帐户。如果您能为我报告这个问题,我将不胜感激。谢谢好的,我为您报告了这个bug:对我来说,它看起来像一个bug,IronPython
的行为应该像CPython
。是否要在GitHub
上打开一个问题?如果你没有账户,我会帮你做的。请让我知道。对不起,我没有GitHub帐户。如果您能为我报告这个问题,我将不胜感激。谢谢好的,我为您报告了错误: