On Mon, Oct 24, 2011 at 01:04:20PM -0500, Johan Martinez wrote:
> 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?

No, you're actualy not. 

> >>> s = "First"
> >>> print s
> First

At this point, you have created a string object with the value "First"
and put that into the variable "s" (which is glossing over a detail about 
how Python variables realy work, but that's another topic).

> >>> s = "Second"
> >>> print s
> Second

Now you created a new string object with the value "Second" and stored THAT
into s, replacing the original object, which is now lost.

-- 
Steve Willoughby    |  Using billion-dollar satellites
st...@alchemy.com   |  to hunt for Tupperware.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to