Modify a string's value

Ben Finney bignose+hates-spam at
Tue Jul 15 16:06:49 CEST 2008

s0suk3 at writes:

> I've heard that a 'str' object is immutable. But is there *any* way to
> modify a string's internal value?

If there were, it would not be immutable. The 'str' type has only
immutable values.

You could implement your own string type, and have it allow mutable
values. You'd have to take care of creating those values explicitly,

 \         “Pinky, are you pondering what I'm pondering?” “I think so, |
  `\      Brain, but shouldn't the bat boy be wearing a cape?” —_Pinky |
_o__)                                                   and The Brain_ |
Ben Finney

More information about the Python-list mailing list