utilities
Utility methods.
FUNCTION | DESCRIPTION |
---|---|
diff_index |
Return the index where iterable2 is different from iterable1. |
eval_if_callable |
Tries to evaluate |
is_action |
Returns |
is_pipeline |
Returns |
pairs |
Return successive pairs taken from the input iterable. |
resolve_name |
Get a key or attr |
Functions¶
diff_index
¶
Return the index where iterable2 is different from iterable1.
eval_if_callable
¶
pairs
¶
Return successive pairs taken from the input iterable.
Like itertools.pairwise
in 3.10, but will always include the last element by itself.
Example
list(pairs(“ABCD”)) [(“A”, “B”), (“B”, “C”), (“C”, “D”), (“D”, None)] list(pairs(“ABC”)) [(“A”, “B”), (“B”, “C”), (“C”, None)]
PARAMETER | DESCRIPTION |
---|---|
iterable
|
The iterable to combine into pairs.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable
|
An iterable of pairs. |
resolve_name
¶
Get a key or attr name
from obj or default value.
Copied and modified from Django Template variable resolutions
Resolution methods:
- Mapping key lookup
- Attribute lookup
- Sequence index
PARAMETER | DESCRIPTION |
---|---|
obj
|
The object to access
TYPE:
|
name
|
A dotted name to the value, such as
TYPE:
|
default
|
If the name cannot be resolved from the object, return this value
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The value at the resolved name or the default value. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If accessing the property raises one of these exceptions. |
AttributeError
|
If accessing the property raises one of these exceptions. |