function that modifies a string

Steven D'Aprano steve at REMOVETHIScyber.com.au
Mon Jul 10 11:06:53 EDT 2006


On Mon, 10 Jul 2006 15:23:36 +0100, Sion Arrowsmith wrote:

> Steven D'Aprano  <steve at REMOVETHIScyber.com.au> wrote:
>>Of course, another right way would be to have mutable strings in Python.
> 
> What significant advantage would mutable strings have over StringIO
> and wrapping list manipulation in list(s) and ''.join(l). Other than
> that pleasing symmetry with sets/frozensets etc.

Some algorithms (e.g. genetic algorithms) have natural implementations
in terms of mutable strings.

StringIO is more like a kind of file than a kind of string. It has no
methods for upper/lowercase, searching, etc. While files do have random
access, they don't have random access insertion and deletion like lists or
hypothetical mutable strings, so StringIO is no replacement at all.


-- 
Steven.




More information about the Python-list mailing list