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
selfandotherby keysIf
sorted_self < sorted_other, returnFalseIf 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], returnTrueReturn
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 todefaultifdefaultis not None andkeyis not in this dict.Raise: KeyError: If
keyis not in this dict anddefaultisNone
- 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
itemis not in this list anddefaultisNone
- 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
selfandotherfor partial ordering. Sortsselfandother, 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
itemif it is in this set. Short for βrequireβ. Falls back todefaultifdefaultis notNone.- Raises
KeyError β If
itemis not in this set anddefaultisNone
- to_frozenset(self) AbstractSet[T]ο
- to_set(self) AbstractSet[T]ο