<div dir="ltr">Hi Deb,<div><br></div><div>          Immutability means that once "This is a string" is created in memory , the string cannot be changed. When we assign a_string with "A different string" this "A different string" is in a new memory location again (a new object) . "This is a string" and "A different string" are two different objects which are in existence which have been assigned to the variable a_string at different points in time. </div>
<div> </div><div>          Now if  "This is a string" is no longer referenced in the scope of the program , the reference count drops to zero at which point it is taken out of memory. Even though we perform a string concatenation and change the string from "A different string" to "A different string appended with some more words" , a new object is created , the initial string "A different string" is copied to this newly created object, "appended with some more words" are added to arrive at the final "A different string appended with some more words". The original "A different string" still remains until the point wherein it is not longer referenced after which it is cleaned up.<br>
</div><div><br></div><div>Thanks.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 3, 2014 at 10:36 AM, Deb Wyatt <span dir="ltr"><<a href="mailto:codemonkey@inbox.com" target="_blank">codemonkey@inbox.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br>
> -----Original Message-----<br>
> From: <a href="mailto:ben@benfinney.id.au">ben@benfinney.id.au</a><br>
> Sent: Tue, 03 Jun 2014 14:54:01 +1000<br>
> To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>
> Subject: Re: can someone explain the concept of "strings (or whatever)<br>
> being immutable"<br>
><br>
> Deb Wyatt <<a href="mailto:codemonkey@inbox.com">codemonkey@inbox.com</a>> writes:<br>
><br>
>> [no text]<br>
><br>
> Deb, can you expand a bit – and write the question in the body of your<br>
> message? It's not clear what you want explained.<br>
><br>
> --<br>
>  \          “I hope if dogs ever take over the world, and they chose a |<br>
>   `\    king, they don't just go by size, because I bet there are some |<br>
> _o__)                   Chihuahuas with some good ideas.” —Jack Handey |<br>
> Ben Finney<br>
><br>
> --<br>
> <a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div>that's strange that you see no text.  The body of my email was as follows:<br>
<div class=""><br>
"""a_string = "This is a string"<br>
a_string is pointing to the above string<br>
<br>
now I change the value of a_string<br>
a_string = "This string is different"<br>
I understand that now a_string is pointing to a different string than it was before, in a different location.<br>
<br>
my question is what happens to the original string??  Is it still in memory somewhere, nameless?<br>
"""<br>
</div>That was just the first question.  What does immutable really mean if you can add items to a list? and concatenate strings?  I don't understand enough to even ask a comprehensible question, I guess.<br>
<br>
<br>
Thanks in advance,<br>
Deb in WA, USA<br>
<br>
____________________________________________________________<br>
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!<br>
Check it out at <a href="http://www.inbox.com/earth" target="_blank">http://www.inbox.com/earth</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>             *****HAVE A NICE DAY *****<br> <br>                         Prashanth
</div>