Preferred method for "Assignment by value"

hall.jeff at hall.jeff at
Tue Apr 15 20:19:28 CEST 2008

I think the fundamental "disconnect" is this issue of mutability and
immutability that people talk about (mainly regarding tuples and
whether they should be thought of as static lists or not)

Coming from VBA I have a tendency to think of everything as an

So when I create the following

test=[1,2],[3,4],[5,6] I'm annoyed to find out that I can change do
the following
test[1][1] = 3
but i can't do
test[1] = [3,3]
and so I throw tuples out the window and never use them again...

The mental disconnect I had (until now) was that my original tuple was
in affect "creating" 3 objects (the lists) within a 4th object (the
tuple)... Previously, I'd been thinking of the tuple as one big object
(mentally forcing them into the same brain space as multi-dimensional
arrays in VBA)

This was a nice "aha" moment for me...

More information about the Python-list mailing list