function that modifies a string

Diez B. Roggisch deets at nospam.web.de
Tue Jul 11 04:49:00 EDT 2006


> 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.

Well, they certainly aren't more dangerous than other mutable objects in
python. But in comparison to only dealing with immutable collections, using
immutable strings never made something impossible or even hard to do - at
least for me. Sometimes a bit harder to do efficiently.

So - the overall danger of mutability can be avoided with immutable strings
pretty neat, and thus one should (or could) go without them.

Regards,

Diez



More information about the Python-list mailing list