为什么我得到“return self.__hash__()
当我使用默认哈希方法时,运行时错误:超出最大递归深度?
This causes the error:
def __hash__(self):
return self.__hash__()
This works:
def __hash__(self):
return self.name.__hash__()
最佳答案
当然,您会通过从自身调用方法来进入无限递归:
def method_name(self):
return self.method_name()
您可能想调用基类的方法?
def __hash__(self):
return super(ClassName, self).__hash__()
关于python - 运行时错误: maximum recursion depth exceeded using default hash method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23289426/