I'm trying to create a transparent wrap: a class which passes all references (apart from some few) to one of its fields. I have got this:
class Wrap():
def __init__(self,val,parent):
self.__dict__['val']=val
self.__dict__['parent']=parent
def SetValue(self,val):
self.__dict__['val']=val
def __getattr__(self,attr):
return self.__dict__['val'].__getattribute__(attr)
def __setattr__(self,attr,val):
self.__dict__['val'].__setattribute__(attr,val)
The problem is that the wrap doesn't seems to pass __getitem__/__setitem__
calls and I get TypeError: 'Wrap' object does not support item assignment
when I try subscript the wrap
, although val
is subscriptable. Is it any workaround?