Skip to main content

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

NameTypeDescription
iterableiterable = nullAn 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

NameTypeDescription
keystrThe string key to look up across the list of subcontexts.
defaultAny = NoneThe value to return if the specified key does not exist in any subcontext.

Returns

TypeDescription
AnyThe value associated with the key if found; otherwise, the provided default value.

keys()

@classmethod
def keys() - > set

Flattened keys of subcontexts.

Returns

TypeDescription
setA set containing all unique keys aggregated from every subcontext in the list.