Functional¶
chanfig.to_dict
¶
Convert an object to a dict.
Note that when converting a set
object, it may be converted to a tuple
object if its values is not hashable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Any
|
Object to be converted. |
required |
Returns:
Type | Description |
---|---|
Mapping | Sequence | Set
|
A dict. |
Examples:
Source code in chanfig/flat_dict.py
options: heading_level: 0
chanfig.save
¶
Save FlatDict
to file.
Raises:
Type | Description |
---|---|
ValueError
|
If save to |
TypeError
|
If save to unsupported extension. |
Alias:
save
Examples:
Source code in chanfig/functional.py
options: heading_level: 0
chanfig.load
¶
Load a file into a FlatDict
.
This function simply calls cls.load
, by default, cls
is NestedDict
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
PathStr
|
The file to load. |
required |
|
type[FlatDict]
|
The class of the file to load. Defaults to |
NestedDict
|
|
Any
|
The arguments to pass to |
()
|
|
Any
|
The keyword arguments to pass to |
{}
|
See Also
Examples:
Python Console Session | |
---|---|
Source code in chanfig/functional.py
options: heading_level: 0
chanfig.apply
¶
Apply func
to all children of obj
.
Note that this method is meant for non-in-place modification of obj
and should return the original object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Any
|
Object to apply function. |
required |
|
Callable
|
Function to be applied. |
required |
|
Any
|
Positional arguments to be passed to |
()
|
|
Any
|
Keyword arguments to be passed to |
{}
|
Returns:
Type | Description |
---|---|
Any
|
Return value of |
See Also
apply_
: Apply an in-place operation.
Source code in chanfig/nested_dict.py
options: heading_level: 0
chanfig.apply_
¶
Apply func
to all children of obj
.
Note that this method is meant for non-in-place modification of obj
and should return a new object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Any
|
Object to apply function. |
required |
|
Callable
|
Function to be applied. |
required |
|
Any
|
Positional arguments to be passed to |
()
|
|
Any
|
Keyword arguments to be passed to |
{}
|
Returns:
Type | Description |
---|---|
Any
|
Return value of |
See Also
apply_
: Apply a non-in-place operation.
Source code in chanfig/nested_dict.py
options: heading_level: 0