#!/usr/bin/env python
# -*- encoding:utf-8-*-
import time

def elapsed_time(functor):
    def decorated(*args, **kwargs):
        start = time.time()
        functor()
        end = time.time()
        print "Elapsed time: %f" % (end-start)
    return decorated

@elapsed_time
def hello():
    print 'hello'

위의 코드는 다음과 동일.

def hello(*args, **kwargs):
    print 'hello'

를 정의후 다음을 호출하는것과 같음

hello = elapsed_time(hello)