bveliqi
9/14/2013 - 9:42 AM

A simple python decorator.

A simple python decorator.

def logcall(f):
  def wrapper(*a, **opts):
    print('calling ' + f.__name__)
    f(*a, **opts)
    print('called ' + f.__name__)
  return wrapper


@logcall
def square(x):
  print 'result: ' + str(x * x)
  return x * x


square(2)