<s> class EventSource ( object ) : <EOL> """<STR_LIT>""" <EOL> _events = { } <EOL> @ classmethod <EOL> def bind ( cls , event , handler ) : <EOL> cls . _events . setdefault ( cls , { } ) . setdefault ( event , [ ] ) . append ( handler ) <EOL> def emit ( self , event , ** data ) : <EOL> try : <EOL> for handler in self . _events [ self . __class__ ] [ event ] : <EOL> handler ( self , ** data ) <EOL> except KeyError : <EOL> pass </s>
