torchoutil.pyoutil.inspect module

get_argnames(
fn: Callable,
) List[str][source]

Get arguments names of a method, function or callable object.

get_current_fn_name(
*,
default: T = '',
) str | T[source]
get_fullname(
x: Any,
*,
inst_suffix: str = '(...)',
) str[source]

Returns the classname of an object with parent modules.

Args:

obj: Object to scan. inst_suffix: Suffix appended to the classname in case the object is an instance of a class.

Example 1

>>> get_fullname([0, 1, 2])
... 'builtins.list(...)'
>>> get_fullname(1.0)
... 'builtins.float(...)'
>>> class A: def f(self): return 0
>>> a = A()
>>> get_fullname(a)
... '__main__.A(...)'
>>> get_fullname(A)
... '__main__.A'
>>> get_fullname(a.f)
... '__main__.A.f'
>>> get_fullname(A.f)
... '__main__.A.f'