Removes one or more previously registered hooks by the function name.
Parameters
place — str, required
The hook from which to remove a function. If this is the only argument, all hooks to
place
will be removed.fname — str|list[str], required
The name of the function registered to the hook, or a list of such names. Hooks registered with an argument-less
@heli.hook
decorator will have the same name asplace
.removeall — bool, optional
By default, this function will stop after the first instance of a hook function matching
name
. Settingremoveall=True
will remove all functions with the given name. This might be the case if multiple functions are hooked using an argument-less@heli.hook
, in which case the functions will all have the name of the hook.Default value: False
Return Value — bool|list[bool]
Whether a matching named hook function in fact existed and was removed, or a list corresponding to the elements of the name
parameter if a list was passed.
charwick
Nov 29, 2020 at 16:46A few examples of hooking and unhooking:
It is recommended to use the
@heli.hook('hookName')
syntax with a unique function name, as in function 3 above, if you plan to remove the hook later.