A class that wraps the object specified at initialization.
I used it as a reference (Malpac r)
-Method Missing in Python --kogelab :: memo
I only added setattr.
class Wrapper():
def __init__(self, base):
self.base = base
def __getattr__( self, name ):
def _method_missing( *args ):
return args
return getattr( self.data, name, _method_missing)
def __setattr__(self, name, value):
if name in dir(self.data):
return setattr(self.data, name, value)
else:
return super(Wrapper, self).__setattr__(name, value)
Recommended Posts