Monday, October 25, 2010

Самый простой декоратор

def print_value(func):
def wrapper(*args, **kwargs):
output = func(*args, **kwargs)
print output
return wrapper

@print_value
def return1():
return 1

@print_value
def return_tuple():
return (1, 2, 3)

No comments: