call_stringο
- plasmapy.utils.code_repr.call_string( ) str[source]ο
Approximate a call of a function or class with positional and keyword arguments.
- Parameters:
f (callable) β A function, class, or other callable object.
args (
tuple,list, or anyobject; optional) β Atupleorlistcontaining positional arguments, or any otherobjectif there is only one positional argument.kwargs (
dict, optional) β Adictcontaining keyword arguments.max_items (
int, default: 12) β The maximum number of items to include in andarrayorQuantity; additional items will be truncated with an ellipsis.
- Returns:
Approximation to a call of
fwithargsas positional arguments andkwargsas keyword arguments.- Return type:
See also
Notes
This function will generally provide an exact call string for most common types of simple positional and keyword arguments. When dealing with types that are not accounted for, this function will fall back on
repr.This function assumes aliases of
uforastropy.unitsandnpfornumpy.Examples
>>> call_string(int, 3.14159) 'int(3.14159)' >>> call_string(int, args=(9.2,), kwargs={"base": 2}) 'int(9.2, base=2)'