Skip to content

freezable¤

Freezable objects (can be made read only).

FreezableMap ¤

FreezableMap(*, read_only, **kwargs)

Bases: MutableMapping[str, VT]

A key-value map that can be made read only.

Parameters:

Name Type Description Default
read_only bool

Whether the mapping is initially in read-only mode (frozen).

required
kwargs VT

All other keyword arguments are used to create the underlying map object.

{}
Source code in src/msl/io/freezable.py
17
18
19
20
21
22
23
24
25
def __init__(self, *, read_only: bool, **kwargs: VT) -> None:
    """A key-value map that can be made read only.

    Args:
        read_only: Whether the mapping is initially in read-only mode (frozen).
        kwargs: All other keyword arguments are used to create the underlying map object.
    """
    self._read_only: bool = bool(read_only)
    self._mapping: dict[str, VT] = dict(**kwargs)

read_only property writable ¤

read_only

bool — Whether the map is in read-only mode.

clear ¤

clear()

Maybe remove all items from the map, only if the map is not in read-only mode.

Source code in src/msl/io/freezable.py
58
59
60
61
def clear(self) -> None:
    """Maybe remove all items from the map, only if the map is not in read-only mode."""
    self._raise_if_read_only()
    self._mapping.clear()

items ¤

items()

ItemsView[str, VT] — Return a view of the map's items.

Source code in src/msl/io/freezable.py
71
72
73
def items(self) -> ItemsView[str, VT]:
    """[ItemsView][collections.abc.ItemsView][[str][], VT] — Return a view of the map's items."""
    return ItemsView(self)

keys ¤

keys()

KeysView[str] — Returns a view of the map's keys.

Source code in src/msl/io/freezable.py
63
64
65
def keys(self) -> KeysView[str]:
    """[KeysView][collections.abc.KeysView][[str][]] — Returns a view of the map's keys."""
    return KeysView(self)

values ¤

values()

ValuesView[VT] — Returns a view of the map's values.

Source code in src/msl/io/freezable.py
67
68
69
def values(self) -> ValuesView[VT]:
    """[ValuesView][collections.abc.ValuesView][VT] — Returns a view of the map's values."""
    return ValuesView(self)