utils.func_tools module¶
Function tools for python
-
borch.utils.func_tools.
args_to_kwargs
(func, *args, **kwargs)¶ Takes function and args and kwargs to that function and converts the args to kwargs.
Note: the argument
self
is removed.- Parameters
func – python callable
*args – non-keyworded variables
**kwargs – keyworded variables
- Returns
dict, with the kwargs to the function
Example
>>> def test_fn(a, b): ... pass >>> args_to_kwargs(test_fn, 1, b=2) {'b': 2, 'a': 1}
-
borch.utils.func_tools.
assign_docs
(new_cls, old_cls, prefix, skip_doctests=True)¶ Update docs on
new_cls
according to how they appear onold_cls
but with added information given byprefix
.
-
borch.utils.func_tools.
disable_doctests
(string)¶ Disable any doctests present in
string
.Notes
This should be done by appending the modifier
# doctest: +SKIP
at the correct position, but this is quite involved. The current fix is to replace and occurrence of {>>>,…} with {>>,..} and start the docs with an empty >>> to make it render correctly.
-
borch.utils.func_tools.
replace_none_with_argument
(argument, func)¶ A decorator which for any function that receives one argument (
value
) replacevalue
withargument
ifvalue
isNone
.