<s> class Counter ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , database , name ) : <EOL> """<STR_LIT>""" <EOL> self . database = database <EOL> self . name = name <EOL> self . key = '<STR_LIT>' % self . name <EOL> if self . key not in self . database : <EOL> self . database [ self . key ] = <NUM_LIT:0> <EOL> def decr ( self , decr_by = <NUM_LIT:1> ) : <EOL> return self . database . decr ( self . key , decr_by ) <EOL> def incr ( self , incr_by = <NUM_LIT:1> ) : <EOL> return self . database . incr ( self . key , incr_by ) <EOL> def value ( self ) : <EOL> return int ( self . database [ self . key ] ) <EOL> def _op ( self , method , other ) : <EOL> if isinstance ( other , Counter ) : <EOL> other = other . value ( ) <EOL> if not isinstance ( other , int ) : <EOL> raise TypeError ( '<STR_LIT>' % other ) <EOL> method ( other ) <EOL> return self <EOL> def __iadd__ ( self , other ) : <EOL> return self . _op ( self . incr , other ) <EOL> def __isub__ ( self , other ) : <EOL> return self . _op ( self . decr , other ) <EOL> __add__ = __iadd__ <EOL> __sub__ = __isub__ </s>
