Unexpected behavior for python set.__contains__

前端 未结 3 1406
盖世英雄少女心
盖世英雄少女心 2020-12-11 02:54

Borrowing the documentation from the __contains__ documentation

print set.__contains__.__doc__
x.__contains__(y) <==> y in x.
3条回答
  •  不思量自难忘°
    2020-12-11 03:35

    This is because CA doesn't implement __hash__

    A sensible implementation would be:

    def __hash__(self):
        return hash(self.name)
    

提交回复
热议问题