![](/img/trans.png)
[英]What RPC module should I use to implement RCP in Python and be able to change connection method later?
[英]What method should I override to implement custom membership test?
我說有課,我做了A的一組實例
s = set(A(1), A(2)...)
我如何通過使用本地“ in”運算符來測試實例是否在s中,例如
if A(3) in s:
...
像dict
一樣,您需要覆蓋__hash__
和__eq__
有關更多詳細信息,請參見https://docs.python.org/2/library/sets.html
因此,設置元素的要求與字典鍵的要求相同; 即,該元素同時定義了eq ()和hash ()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.