Re: [問題] membership test

看板Python作者 ([][][])時間17年前 (2008/03/31 22:31), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《huggie (huggie)》之銘言: : 我自訂了一個 class ..裡面有個 dictionary 的 member : 對 dictionary inheritance 不熟,貪快所以直接用包的。 : __getitem__ 可以用來做 index : 我就用來 proxy (是這樣稱呼嗎) 裡面的那個 dictionary : 但是 membership test 好像不能用 (例如 'xxx' in dic) : 明明沒有在 dictionary 裡面居然 pass 了 : 請問要怎麼用? http://docs.python.org/ref/comparisons.html For user-defined classes which define the __contains__() method, x in y is true if and only if y.__contains__(x) is true. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.143.225.229

03/31 23:03, , 1F
3Q
03/31 23:03, 1F
文章代碼(AID): #17yFMdrY (Python)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
文章代碼(AID): #17yFMdrY (Python)