formations/algo/poo/cours/snippets/wrap.py

23 lines
583 B
Python
Raw Permalink Normal View History

2017-09-05 09:25:48 +02:00
class Wrap(object):
def __init__(self, name, wrap):
self.slots = ('_name', '_w')
self._name = name or "wrapped_element"
self._w = wrap
def __getattr__(self, name):
if name in self.slots:
return getattr(self, name)
else:
return getattr(self._w, name)
# def get_w(self, name):
# return getattr(self._w, name)
# def set_w(self, name, value):
# return setattr(self._w, name, value)
# _w = property (get_w, set_w)
def __repr__(self):
return "[W_Element %s]"% repr(self._name)