> Thanks I will try all of that, but what does really means mutating in
> python? It's the first time I hear this word in programming :))

An object is called mutable if you can alter it - immutable otherwise. In
java and python e.g. strings are immutable. In python, tuples are
immutable:

>>> a = (1,2)
>>> a[0] = 3
TypeError: object doesn't support item assignment

but lists are mutable:

>>> a = [1,2]
>>> a[0] = 3
>>> a
[3,2]

But objects in tuples can be mutable:

>>> a = (1, [2,3])
>>> a[1].append(4)
>>> a
(1,[2,3,4])

Numbers are also immutable. 1 is 1 always. 


The most important thing to know about python and variables is that
variables are only names pointing/referring to values. You might be able to
modify the values if they are mutable, but assigning a value to a variable
means that you simply rebind its name to a new value - not that you alter
it. Consider this:

>>> a = 1
>>> b = a
>>> a = 2
>>> print a, b
2 1



-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to