can someone explain the concept of "strings (or whatever) being immutable"

Deb Wyatt codemonkey at inbox.com
Tue Jun 3 01:06:37 EDT 2014



> -----Original Message-----
> From: ben at benfinney.id.au
> Sent: Tue, 03 Jun 2014 14:54:01 +1000
> To: python-list at python.org
> Subject: Re: can someone explain the concept of "strings (or whatever)
> being immutable"
> 
> Deb Wyatt <codemonkey at inbox.com> writes:
> 
>> [no text]
> 
> Deb, can you expand a bit – and write the question in the body of your
> message? It's not clear what you want explained.
> 
> --
>  \          “I hope if dogs ever take over the world, and they chose a |
>   `\    king, they don't just go by size, because I bet there are some |
> _o__)                   Chihuahuas with some good ideas.” —Jack Handey |
> Ben Finney
> 
> --
> https://mail.python.org/mailman/listinfo/python-list
that's strange that you see no text.  The body of my email was as follows:

"""a_string = "This is a string"
a_string is pointing to the above string

now I change the value of a_string
a_string = "This string is different"
I understand that now a_string is pointing to a different string than it was before, in a different location.

my question is what happens to the original string??  Is it still in memory somewhere, nameless?
"""
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.


Thanks in advance,
Deb in WA, USA

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
Check it out at http://www.inbox.com/earth





More information about the Python-list mailing list