I do the following
class dumb(object):
def __init__(self):
self.g = {}
def __getitem__(self,key): return self.g[key] if key in self.g else None
def __setitem__(self,key,val):
self.g[key] = val
te = dumb()
te[1]=2
te[1]
Out[4]: 2
1 in te
and it hangs..
So if I want to search something like this, how do i do that? Please don't tell me to subclass class dictionary.
Thanks in advance!
Possible relevant question asked here: What does __contains__ do, what can call __contains__ function