Not exactly sure what you're asking since there's no sample code in your question, but here's a guess:
import functools
#from utilities import my_decorator # in-lined below for simplicity
def my_decorator(control):
def wrapper(function):
" Do something with function or before and after it returns. """
@functools.wraps(function)
def wrapped(*args, **kwargs):
print('doing something with {!r} control before calling {}()'.format(
control, function.__name__))
return function(*args, **kwargs)
return wrapped
return wrapper
class Test(object):
def foo(self):
print('in method foo')
@my_decorator('baz')
def bar(self):
print('in method bar')
test = Test()
test.foo()
test.bar()
Output:
in method foo
doing something with 'baz' control before calling bar()
in method bar