 class Observable : <EOL> '''<STR_LIT>''' <EOL> _observers = None <EOL> def addobserver ( self , observer ) : <EOL> if not self . _observers : <EOL> self . _observers = [ ] <EOL> self . _observers . append ( observer ) <EOL> def removeobserver ( self , observer ) : <EOL> if observer in self . _observers : <EOL> self . _observers . remove ( observer ) <EOL> def notify ( self , event ) : <EOL> for o in self . _observers or ( ) : <EOL> o ( event ) <EOL> class ObservableDict ( dict , Observable ) : <EOL> def __setitem__ ( self , key , value ) : <EOL> dict . __setitem__ ( self , key , value ) <EOL> self . notify ( ( key , value ) ) <EOL> def __delitem__ ( self , key ) : <EOL> dict . __delitem__ ( self , key ) <EOL> self . notify ( ( key , None ) ) <EOL> def pop ( self , key ) : <EOL> v = dict . pop ( self , key ) <EOL> self . notify ( ( key , None ) ) <EOL> return v <EOL> def clear ( self ) : <EOL> dict . clear ( self ) <EOL> self . notify ( None ) <EOL> import threading <EOL> from functools import wraps <EOL> def delay ( delay = <NUM_LIT:0.> ) : <EOL> """<STR_LIT>""" <EOL> def wrap ( f ) : <EOL> @ wraps ( f ) <EOL> def delayed ( * args , ** kwargs ) : <EOL> timer = threading . Timer ( delay , f , args = args , kwargs = kwargs ) <EOL> timer . start ( ) 
 return delayed 
 class Observable : <EOL> '''<STR_LIT>''' <EOL> _observers = None <EOL> def addobserver ( self , observer ) : <EOL> if not self . _observers : <EOL> self . _observers = [ ] <EOL> self . _observers . append ( observer ) <EOL> def removeobserver ( self , observer ) : <EOL> if observer in self . _observers : <EOL> self . _observers . remove ( observer ) <EOL> def notify ( self , event ) : <EOL> for o in self . _observers or ( ) : <EOL> o ( event ) <EOL> class ObservableDict ( dict , Observable ) : <EOL> def __setitem__ ( self , key , value ) : <EOL> dict . __setitem__ ( self , key , value ) <EOL> self . notify ( ( key , value ) ) <EOL> def __delitem__ ( self , key ) : <EOL> dict . __delitem__ ( self , key ) <EOL> self . notify ( ( key , None ) ) <EOL> def pop ( self , key ) : <EOL> v = dict . pop ( self , key ) <EOL> self . notify ( ( key , None ) ) <EOL> return v <EOL> def clear ( self ) : <EOL> dict . clear ( self ) <EOL> self . notify ( None ) <EOL> import threading <EOL> from functools import wraps <EOL> def delay ( delay = <NUM_LIT:0.> ) : <EOL> """<STR_LIT>""" <EOL> def wrap ( f ) : <EOL> @ wraps ( f ) <EOL> def delayed ( * args , ** kwargs ) : <EOL> timer = threading . Timer ( delay , f , args = args , kwargs = kwargs ) <EOL> timer . start ( ) <EOL> return delayed <EOL> return wrap </s>
