python - i have '__contains__' ,why error -
class a(object): def a(self): return true __contains__=a b=a() print 2 in b#why error
__contains__ meant take argument. a doesn't accept argument.
the following example working __contains__:
>>> class a(object): ... def a(self, item): ... return true ... __contains__=a ... >>> b=a() >>> print 2 in b true
Comments
Post a Comment