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