Modify a string's value

Larry Bates larry.bates at`
Wed Jul 16 01:46:01 CEST 2008

s0suk3 at wrote:
> Hi everyone,
> I've heard that a 'str' object is immutable. But is there *any* way to
> modify a string's internal value?
> Thanks,
> Sebastian

Why would you care?  Just create a new string (with the changed contents) and 
let garbage collection take care of the old one when all the references to it 
have gone away.  Since these types of questions seem to appear almost every day 
on this list, this Python stuff is so much different than old languages people 
have hard time making the conceptual "jump".  You can basically quite worrying 
about how/where things are stored, they just are.


More information about the Python-list mailing list