[Tutor] Copying a mutable

col speed ajarncolin at gmail.com
Wed Jun 8 14:40:13 CEST 2011


I think this is easily seen by a for loop:
for something in range(20):
    print something

In the above "something" is a variable, in this case an int(which is
immutable). However, "something" is changed every time it goes through the
loop.
It's the equivalent of:
x = 0
x = 1
x = 2
and so on
Just because an int is immutable, doesn't mean that you can't change the
"variable" that refers to it.

Hope that helps


--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110608/47f6caa3/attachment-0001.html>


More information about the Tutor mailing list