mutable sequences

Ben Finney ben+python at benfinney.id.au
Thu Jun 14 00:24:46 EDT 2018


Sharan Basappa <sharan.basappa at gmail.com> writes:

> For example, Python lists are mutable.

Yes, that's correct.

> BTW, is the below explanation correct (it is taken from a book I am
> reading)
>
> Python lists are mutable sequences. They are very similar to tuples,
> but they don't have the restrictions due to immutability.
>
> It says lists are mutable and then says they are immutable???

The passage is correct, but is ambiguously phrased.

You appear to be parsing it as:

    Python lists are mutable sequences. They are very similar to tuples,
    but {{they don't have the restrictions} due to immutability}.

which would imply that Python lists are both mutable and are immutable.

Instead, I think the intended parsing is:

    Python lists are mutable sequences. They are very similar to tuples,
    but {they don't have {the restrictions due to immutability}}.

implying that Python lists are mutable; and then contrasting lists
against Python tuples which have “the restrictions due to immutability”.

Does that help?

You might send the publisher a request to clarify the text in a future
edition.

-- 
 \       “To have the choice between proprietary software packages, is |
  `\      being able to choose your master. Freedom means not having a |
_o__)                        master.” —Richard M. Stallman, 2007-05-16 |
Ben Finney




More information about the Python-list mailing list