Function
Function ¶
A Function object represents a function and its attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The function to be inspected. |
required |
skip_self
|
bool
|
Whether to skip the self parameter. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the function. |
docstring |
str
|
The docstring of the function. |
has_docstring |
bool
|
Whether the function has a docstring. |
description |
str
|
The description part of the function's docstring. |
params |
list[Parameter]
|
A list of parameters of the function. |
dict |
dict
|
A dictionary representation of the function's attributes. |
Source code in objinspect/function.py
get_param ¶
Retrieve a single Parameter object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arg
|
str | int
|
Either the name or index of the parameter to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Parameter |
Parameter
|
A |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arg is not a string or an integer. |
Source code in objinspect/function.py
call ¶
call(*args, **kwargs) -> Any
Calls the function and returns the result of its call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Positional arguments passed to the function. |
()
|
|
**kwargs
|
Keyword arguments passed to the function. |
{}
|
Source code in objinspect/function.py
as_str ¶
as_str(*, color: bool = True, description: bool = True, ljust: int = 58, theme: FunctionStrTheme | None = None) -> str
Return a string representation of the function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
bool
|
Whether to colorize the string. |
True
|
description
|
bool
|
Whether to include the description of the function. |
True
|
ljust
|
int
|
The width of the string. |
58
|
theme
|
FunctionStrTheme
|
Color theme to use. Default will be used if None. |
None
|