Skip to content

Collections

collections

EventTarget

__init__(*args, **kwargs)

add_event_listener(type: str, listener: callable)

remove_event_listener(type: str, listener: callable)

dispatch_event(event: str)

MutableCollection

Bases: EventTarget

__init__(*args, **kwargs)

set_parent(parent: MutableCollection) -> MutableCollection

changed()

coerce(value: any)

MutableDict

Bases: MutableCollection, MutableMapping[K, V]

__init__(*args, **kwargs)

__getitem__(key: K) -> V

__setitem__(key: K, value: V)

__delitem__(key: K)

__iter__() -> Generator[K, None, None]

__len__() -> int

__repr__() -> str

MutableList

Bases: MutableCollection, MutableSequence[V]

__init__(*args, **kwargs)

__getitem__(key: int) -> V

__setitem__(key: int, value: V)

insert(index: int, value: V)

__delitem__(key: int)

__len__() -> int

__repr__() -> str

sort(*args, **kwargs) -> None

MutableSet

Bases: MutableCollection, MutableSet[V]

__init__(*args, **kwargs)

add(item: V)

update(*s: Iterable[V]) -> None

discard(item: V)

__contains__(item: V) -> bool

__iter__() -> Generator[V, None, None]

__len__() -> int

__repr__() -> str

flatten(data: Dict[str, Any], *, separator: str = '.', parent_key: Optional[str] = None) -> Dict[Union[str, Tuple[str]], Any]

Flatten a nested dictionary.

Parameters:

Name Type Description Default
data Dict[str, Any]

The nested dictionary to flatten.

required
separator str

The separator, by default "."

'.'
parent_key Optional[str]

The parent key, by default None

None

Returns:

Type Description
Dict[str | tuple[str], Any]

The flattened dictionary.