Modify a string's value

Larry Bates larry.bates at websafe.com`
Tue Jul 15 19:46:01 EDT 2008


s0suk3 at gmail.com 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.

-Larry



More information about the Python-list mailing list