cpdbench.utils.Utils

 1import inspect
 2from typing import Callable
 3
 4"""Utils.py module
 5This module contains various utility functions which are needed by multiple objects in the testbench
 6"""
 7
 8
 9def get_name_of_function(function_ref: Callable) -> str:
10    """Returns the name of the given function reference/object by using the inspect module
11    :param function_ref: the function reference
12    :return: the name of the function
13    """
14    name_gen = (attr[1] for attr in inspect.getmembers(function_ref) if attr[0] == "__name__")
15    return next(name_gen)
def get_name_of_function(function_ref: Callable) -> str:
10def get_name_of_function(function_ref: Callable) -> str:
11    """Returns the name of the given function reference/object by using the inspect module
12    :param function_ref: the function reference
13    :return: the name of the function
14    """
15    name_gen = (attr[1] for attr in inspect.getmembers(function_ref) if attr[0] == "__name__")
16    return next(name_gen)

Returns the name of the given function reference/object by using the inspect module

Parameters
  • function_ref: the function reference
Returns

the name of the function