<s> class Delegator : <EOL> def __init__ ( self , delegate = None ) : <EOL> self . delegate = delegate <EOL> self . __cache = set ( ) <EOL> def __getattr__ ( self , name ) : <EOL> attr = getattr ( self . delegate , name ) <EOL> setattr ( self , name , attr ) <EOL> self . __cache . add ( name ) <EOL> return attr <EOL> def resetcache ( self ) : <EOL> for key in self . __cache : <EOL> try : <EOL> delattr ( self , key ) <EOL> except AttributeError : <EOL> pass <EOL> self . __cache . clear ( ) <EOL> def setdelegate ( self , delegate ) : <EOL> self . resetcache ( ) <EOL> self . delegate = delegate </s>
