ContextList
A wrapper that provides direct key access to context items contained in a list of context objects.
Constructor
Signature
def ContextList(
iterable: iterable = null
) - > None
Parameters
| Name | Type | Description |
|---|---|---|
| iterable | iterable = null | An optional iterable used to initialize the list elements. |
Methods
get()
@classmethod
def get(
key: str,
default: Any = None
) - > Any
Attempts to retrieve the value for a given key from the subcontexts, returning a default value if the key is not found. This provides a safe way to access context data without handling KeyError exceptions.
Parameters
| Name | Type | Description |
|---|---|---|
| key | str | The string key to look up across the list of subcontexts. |
| default | Any = None | The value to return if the specified key does not exist in any subcontext. |
Returns
| Type | Description |
|---|---|
Any | The value associated with the key if found; otherwise, the provided default value. |
keys()
@classmethod
def keys() - > set
Flattened keys of subcontexts.
Returns
| Type | Description |
|---|---|
set | A set containing all unique keys aggregated from every subcontext in the list. |