I've been using Sequence
in type hints for sequences including mutable list
s. Now I've just discovered that there is also MutableSequence
. As far as I can tell, Sequence
is a superclass of MutableSequence
, i.e., Sequence
includes both mutables like list
and immutables like tuple
, while MutableSequence
only includes the former.
Two questions:
- Is this correct? (I'm pretty sure it is, but I haven't found any explicit statement to this end.)
- If so, is there an immutable equivalent to
MutableSequence
that includes, e.g.,tuple
andstr
, but notlist
?