[Tutor] string immutability

Johan Martinez jmartiee at gmail.com
Mon Oct 24 20:04:20 CEST 2011


Hi,

I am struggling to understand Python string immutability. I am able to
modify Python string object after initializing/assigning it a value. So how
does immutability work? I am not following it. Sorry for really stupid
question. Any help?

<code>

>>> s = "First"
>>> print s.__class__
<type 'str'>
>>> print s
First
>>> s = "Second"
>>> print s
Second
>>>

</code>

jM.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111024/8512f28e/attachment.html>


More information about the Tutor mailing list