0
操作我有一類.def
INES的__getitem__
,__setitem__
方法(和keys
和items
也一樣),並表現的像字典,其中鍵是字符串。「在」與升壓::蟒蛇
然而,in
運營商並不像預期的那樣:
>>> myObject=MyClass()
>>> 'abc' in myObject.keys()
False
>>> 'abc' in myObject
ArgumentError: Python argument types in
MyClass.__getitem__(MyClass, int)
did not match the C++ signature:
__getitem__(MyClass {lvalue}, std::string)
爲什麼蟒蛇試圖調用__getitem__
與int
,當我用鑰匙str
?
[documentation](http://docs.python.org/reference/datamodel.html#object.__getitem__)表示「鍵應該是整數和切片對象」。 – unholysampler
您引用的文檔明確指出,這只是需要整數和切片的序列。 – eudoxos