function that modifies a string

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


On Mon, 10 Jul 2006 16:27:03 +0200, Diez B. Roggisch wrote:

>> Of course, another right way would be to have mutable strings in Python.
>> I understand why strings need to be immutable in order to work with dicts,
>> but is there any reason why (hypothetical) mutable strings should be
>> avoided in situations where they aren't needed as dictionary keys? Python
>> has mutable lists and immutable tuples, mutable sets and immutable frozen
>> sets, but no mutable string type.
> 
> What's wrong about arrays of chars?

Nice suggestion. However, I should point out that the methods available to
array.array('c') are quite limited compared to the methods available to
strings. Still, it would make a good basis to start with, and far better
than my initial thought of a list of chars.


-- 
Steven.




More information about the Python-list mailing list