def gethandler(f):
    handlers.append((re.compile(regexp), f))
return f
return gethandler

@handler_for('^<\\w+> (.*)')
def handle_message(msg):
    print(msg)

@handler_for('^\\*{3} (.*)')
def handle_warning(msg):
    global num_warnings, num_fatals
num_warnings += 1
if is_fatal(msg):
    num_fatals += 1
How to make an anonymous function in Python without Christening it?