class Iterable[_T] = (), *, basetype: type[_T] | Sequence[type[_T]] = (), lookup: dict[type[_L], Callable[[_T], _T | _L]] | None = None)[source]#

Bases: MutableSequence[_T]

List mixin that enforces item type, and enables custom indexing.

  • data (iterable, optional) – Elements to initialize the list with.

  • basetype (type or sequence of types, optional) – Type of the elements in the list. If a basetype (or multiple) is provided, then a TypeError will be raised when attempting to add an item to this sequence if it is not an instance of one of the types in basetype.

  • lookup – Mapping between a type, and a function that converts items in the list to that type. This is used for custom indexing. For example, if a lookup of {str: lambda x:} is provided, then you can index into the list using list['frank'] and it will search for an object whos attribute .name equals 'frank'.



S.append(value) -- append value to the end of the sequence



Return a shallow copy of the list.



S.extend(iterable) -- extend sequence by appending elements from the iterable

index(value[, start, stop])

Return first index of value.

insert(index, value)

S.insert(index, value) -- insert value before index


Raise IndexError if list is empty or index is out of range.


S.remove(value) -- remove first occurrence of value.


S.reverse() -- reverse IN PLACE


copy() TypedMutableSequence[_T][source]#

Return a shallow copy of the list.

index(value: _L, start: int = 0, stop: int | None = None) int[source]#

Return first index of value.

  • value (Any) – A value to lookup. If type(value) is in the lookups functions provided for this class, then values in the list will be searched using the corresponding lookup converter function.

  • start (int, optional) – The starting index to search, by default 0

  • stop (int, optional) – The ending index to search, by default None


The index of the value

Return type:



ValueError – If the value is not present

insert(index: int, value: _T) None[source]#

S.insert(index, value) – insert value before index