def addn(n): def entangle(func): def call(func, *args, **kw): return func(*args, **kw) + n return call return decorator(entangle)
def sig_changer(): def entangle(func): def call(func, a, b): return func(b) return call return decorator(entangle, (["a", "b"], None, None, None))
import unittest from gearshift.decorator import * def d1(func): def call(func, *args, **kw): return func(*args, **kw) return call d1 = decorator(d1) def d2(func): def call(func, *args, **kw): return func(*args, **kw) return call d2 = decorator(d2) def d3(func): func.baz2 = 2 def call(func, *args, **kw): return func(*args, **kw) return call d3 = decorator(d3) def foo(a, b): return a+b foo.baz1 = 1 bar = foo foo = d1(foo)