String Splice Assignment

Erno Kuusela erno-news at erno.iki.fi
Mon Jul 16 21:17:09 EDT 2001


In article <4e3a8319.0107161357.690b5120 at posting.google.com>,
gervaserules at yahoo.com (eAndroid) writes:

| Why don't strings support splice assignment, and what are some
| alternatives?

as others have noted, strings are immutable. probably because
the python "everything is a reference" semantics would make
accidentally change someone else's string a frequent bug, and
for efficiency reasons.

you can use the array module, or a list, if you need a mutable
sequence of characters. lists are a bit less hassle, use array if you
need to worry about memory usage.

  -- erno




More information about the Python-list mailing list