def mirror_from(source, attributes, only_getters=True):
 def decorator(cls):
  for attribute in attributes:
   def make_gs_etter(source, attribute):
    def getter(self):
     return getattr(getattr(self, source), attribute)
    def setter(self, value):
     setattr(getattr(self, source), attribute, value)
    return (getter, setter)
   (getter, setter) = make_gs_etter(source, attribute)
   if only_getters:
    setattr(cls, attribute, property(getter))
   else:
    setattr(cls, attribute, property(getter, setter))
  return cls
 return decorator

def mirror_from ( source , attributes , only_getters = True ) : def decorator ( cls ) : for attribute in attributes : def make_gs_etter ( source , attribute ) : def getter ( self ) : return getattr ( getattr ( self , source ) , attribute ) def setter ( self , value ) : setattr ( getattr ( self , source ) , attribute , value ) return ( getter , setter ) ( getter , setter ) = make_gs_etter ( source , attribute ) if only_getters : setattr ( cls , attribute , property ( getter ) ) else : setattr ( cls , attribute , property ( getter , setter ) ) return cls return decorator
decorator for classes that mirror some attributes from an instance variable .