<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="generator" content="Osso Notes">
    <title></title></head>
<body>
<p>On Mon, 24 Oct 2011, 20:04:20 CEST, Johan Martinez &lt;<a href="mailto:jmartiee@gmail.com">jmartiee@gmail.com</a>&gt; wrote:
<br>
<br>&gt; I am struggling to understand Python string immutability. I am able to
<br>&gt; modify Python string object after initializing/assigning it a value. So
<br>&gt; how does immutability work? I am not following it. Sorry for really
<br>&gt; stupid question. Any help?
<br>
<br>Mutibility means changinging the object (string) in place. What you are doing below is creating a new string and asigning it to a variable.
<br>&#32;
<br>&gt; &lt;code&gt;
<br>&gt; 
<br>&gt; &gt; &gt; &gt; s = "First"
<br>&gt; &gt; &gt; &gt; print s.__class__
<br>&gt; &lt;type 'str'&gt;
<br>&gt; &gt; &gt; &gt; print s
<br>&gt; First
<br>&gt; &gt; &gt; &gt; s = "Second"
<br>&gt; &gt; &gt; &gt; print s
<br>&gt; Second
<br>&gt; &gt; &gt; &gt; 
<br>&gt; 
<br>&gt; &lt;/code&gt;
<br>
<br>If the object s reffernces is mutable you should be able to do:
<br>
<br>s[0] = 'x'
<br>
<br>Try it and see what happen. Then also try this with a list of strings 
<br>
<br>s = ['f', 'i', 'r', 's', 't']
<br>s[0] = 'x'
<br>
<br>Greets
<br>sander</p>
</body>
</html>