util
call_method ¶
Call a method with the given name on the given object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to call the method on. |
required |
name
|
str
|
The name of the method to call. |
required |
args
|
tuple
|
The positional arguments to pass to the method. |
()
|
kwargs
|
dict
|
The keyword arguments to pass to the method. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
object |
Any
|
The result of calling the method. |
Source code in objinspect/util.py
get_uninherited_methods ¶
Get the methods of a class that are not inherited from its parent classes.
Source code in objinspect/util.py
create_function ¶
create_function(name: str, args: dict[str, tuple[Any, Any]], body: str | list[str], globs: dict[str, Any], return_type: Any | EMPTY = EMPTY, docstring: str | None = None) -> Callable[..., Any]
Create a function with the given name, arguments, body, and globals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the function. |
required |
args
|
dict
|
A dictionary mapping argument names to tuples of the argument type and default value. |
required |
body
|
str | list
|
The body of the function. If a string, it will be split by newlines. |
required |
globs
|
dict
|
The globals to use when executing the function. |
required |
return_type
|
Any
|
The return type of the function. |
EMPTY
|
docstring
|
str
|
The docstring of the function. |
None
|