def __call__(self, mo):
        """ This handler will be invoked for each regex match """

        # Count substitutions
        self.count += 1  # Look-up string

        return self[mo.string[mo.start():mo.end()]]
def __call__ ( self , mo ) : self . count += 1 return self [ mo . string [ mo . start ( ) : mo . end ( ) ] ]
This handler will be invoked for each regex match