I need to use sequence of items as dict key and to feat List[...]
type. If I use tuple
, than it does not feat to a List[...]
type and I cannot use Tuple[...]
type, because tuple length is not known.
Is there any class (maybe from a 3rd party package) to be like hashable frozen list?
The immutable equivalent to List[T]
is Tuple[T, ...]
.
From the Python documentation:
To specify a variable-length tuple of homogeneous type, use literal ellipsis, e.g.
Tuple[int, ...]
. A plainTuple
is equivalent toTuple[Any, ...]
, and in turn totuple
.