typeddfs.frozen_types
ο
Hashable and ordered collections.
Module Contentsο
- class typeddfs.frozen_types.FrozeDict(dct: Mapping[K, V])ο
An immutable dictionary/mapping. Hashable and ordered.
- EMPTY :FrozeDictο
- __contains__(self, item: K) bool ο
- __getitem__(self, item: K) T ο
- __hash__(self) int ο
Return hash(self).
- __iter__(self)ο
- __len__(self) int ο
- __lt__(self, other: Mapping[K, V])ο
Compares this dict to another, with partial ordering.
- The algorithm is:
Sort
self
andother
by keysIf
sorted_self < sorted_other
, returnFalse
If the reverse is true (
sorted_other < sorted_self
), returnTrue
(The keys are now known to be the same.) For each key, in order: If
self[key] < other[key]
, returnTrue
Return
False
- __repr__(self) str ο
Return repr(self).
- __str__(self) str ο
Return str(self).
- get(self, key: K, default: Optional[V] = None) Optional[V] ο
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- property is_empty(self) bool ο
- items(self) AbstractSet[tuple[K, V]] ο
D.items() -> a set-like object providing a view on Dβs items
- keys(self) AbstractSet[K] ο
D.keys() -> a set-like object providing a view on Dβs keys
- property length(self) int ο
- req(self, key: K, default: Optional[V] = None) V ο
Returns the value corresponding to
key
. Short for βrequireβ. Falls back todefault
ifdefault
is not None andkey
is not in this dict.Raise: KeyError: If
key
is not in this dict anddefault
isNone
- to_dict(self) MutableMapping[K, V] ο
- values(self) ValuesView[V] ο
D.values() -> an object providing a view on Dβs values
- class typeddfs.frozen_types.FrozeList(lst: Sequence[T])ο
An immutable list. Hashable and ordered.
- EMPTY :FrozeListο
- __getitem__(self, item: int)ο
- __hash__(self) int ο
Return hash(self).
- __iter__(self) Iterator[T] ο
- __len__(self) int ο
- __repr__(self) str ο
Return repr(self).
- __str__(self) str ο
Return str(self).
- get(self, item: T, default: Optional[T] = None) Optional[T] ο
- property is_empty(self) bool ο
- property length(self) int ο
- req(self, item: T, default: Optional[T] = None) T ο
Returns the requested list item, falling back to a default. Short for βrequireβ.
- Raises
KeyError β If
item
is not in this list anddefault
isNone
- to_list(self) List[T] ο
- class typeddfs.frozen_types.FrozeSet(lst: AbstractSet[T])ο
An immutable set. Hashable and ordered. This is almost identical to
typing.FrozenSet
, but itβs behavior was made equivalent to those of FrozeDict and FrozeList.- EMPTY :FrozeSetο
- __contains__(self, x: T) bool ο
- __getitem__(self, item: T) T ο
- __hash__(self) int ο
Return hash(self).
- __iter__(self) Iterator[T] ο
- __len__(self) int ο
- __lt__(self, other: Union[FrozeSet[T], AbstractSet[T]])ο
Compares
self
andother
for partial ordering. Sortsself
andother
, then compares the two sorted sets.- Approximately::
return list(sorted(self)) < list(sorted(other))
- __repr__(self) str ο
Return repr(self).
- __str__(self) str ο
Return str(self).
- get(self, item: T, default: Optional[T] = None) Optional[T] ο
- property is_empty(self) bool ο
- property length(self) int ο
- req(self, item: T, default: Optional[T] = None) T ο
Returns
item
if it is in this set. Short for βrequireβ. Falls back todefault
ifdefault
is notNone
.- Raises
KeyError β If
item
is not in this set anddefault
isNone
- to_frozenset(self) AbstractSet[T] ο
- to_set(self) AbstractSet[T] ο