function that modifies a string

Steven D'Aprano steve at REMOVETHIScyber.com.au
Mon Jul 10 18:48:01 EDT 2006


On Mon, 10 Jul 2006 19:30:09 +0200, Diez B. Roggisch wrote:

[snip]
 
> So: Yes, mutable strings are dangerous. 

I'm sorry, perhaps I'm being slow today, but just why are they dangerous?
More dangerous than, say, mutable lists and mutable dicts? Unless I'm
missing something, the worst that can happen is that people will write
inefficient code, and they'll be caught out by the same sort of things
that surprise newbies about lists. E.g. using a list as a default value
in function definitions.


> Use them only when their benefits outweigh their risks.

That goes without saying :)


-- 
Steven.




More information about the Python-list mailing list