Difference between revisions of "Python Hooks"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (Created page with " =Hook Functions & Wrappers= <pre> import whatever import functools def prefix_function(function, prefunction): @functools.wraps(function) def run(*args, **kwargs):...") |
(No difference)
|
Latest revision as of 16:02, 20 July 2017
Hook Functions & Wrappers
import whatever
import functools
def prefix_function(function, prefunction):
@functools.wraps(function)
def run(*args, **kwargs):
prefunction(*args, **kwargs)
return function(*args, **kwargs)
return run
def this_is_a_function(parameter):
pass # Your own code here that will be run before
whatever.this_is_a_function = prefix_function(
whatever.this_is_a_function, this_is_a_function)