rex.utilities.fun_utils.get_fun_call_str

get_fun_call_str(fun, config, quote_char='"')[source]

Get a string that will call a function using args and kwargs from a generic config.

Example

If the function signature is my_fun(a, b, c=0) and config is {‘a’: 1, ‘b’: 2, ‘c’: 3}, the returned call string will be “my_fun(1, 2, c=3)”. The function can also take *args or **kwargs, which will be taken from the “args” and “kwargs” keys in the config. “args” must be mapped to a list, and “kwargs” must be mapped to a dictionary.

Parameters
  • fun (obj) – A callable object with a function signature. The function signature will be parsed for args and kwargs which will be taken from the config.

  • config (dict) – A namespace of arguments to run fun. Not all entries in config may be used, but all required inputs to fun must be provided in config. Can include “args” and “kwargs” which must be mapped to a list and a dictionary, respectively.

  • quote_char (str) – Character to use for string quotes in the fun_call_str output.

Returns

fun_call_str (str) – A string representation of a function call e.g. “fun(arg1, arg2, kw1=kw1)” where arg1, arg2, and kw1 were found in the config.