Код: Выделить всё
@process
def foo(x, y):
print x + y
Код: Выделить всё
def process(func=None, **options):
if func != None:
def _call(*args, **kwargs):
if len(options) > 0 and 'fail' in options:
return Process(func, fail=options['fail'], *args, **kwargs)
else:
return Process(func, fail=None, *args, **kwargs)
return _call
else:
def _func(func):
return process(func, **options)
return _func
Код: Выделить всё
def foo(x, y):
get_locals()
print x + y
Возможно ли это вообще? Есть ли более простое/лучшее решение?