看板 Python 關於我們 聯絡資訊
※ 引述《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
huggie:3Q 03/31 23:03