First of all, __init__
is not well indented. Second, you should separate the def
keyword from the actual method name:
class Container(object):
def __init__(self, name):
self.name = name
self.inside = {}
def __iter__(self):
return iter(self.inside.items())
def __len__(self):
return len(self.inside)
def __contains__(self, item):
return item.raw in self.inside
def __getitem__(self, item):
return self.inside[item.raw]
def __setitem__(self, item, value):
self.inside[item.raw] = value
return self[item]
UPDATE: Notice that you're mixing indents, python normally suggest 4 white spaces for indenting, but I see you're using both 4 and 8, you may use whatever you want but stick to it, don't mix them because you may find unexpected behavior.
Hope this helps!