This behaviour is explained in Python's documentation under "Language
reference", topic 3.1 "Objects, values and types" (in 2.5.4):

"Some objects contain references to other objects; these are called
containers. Examples of containers are tuples, lists and dictionaries.
The references are part of a container's value. In most cases, when we
talk about the value of a container, we imply the values, not the
identities of the contained objects; however, when we talk about the
mutability of a container, only the identities of the immediately
contained objects are implied. So, if an immutable container (like a
tuple) contains a reference to a mutable object, its value changes if
that mutable object is changed."

"Types affect almost all aspects of object behavior. Even the
importance of object identity is affected in some sense: for immutable
types, operations that compute new values may actually return a
reference to any existing object with the same type and value, while
for mutable objects this is not allowed. E.g., after "a = 1; b = 1", a
and b may or may not refer to the same object with the value one,
depending on the implementation, but after "c = []; d = []", c and d
are guaranteed to refer to two different, unique, newly created empty
lists. (Note that "c = d = []" assigns the same object to both c and
d.) "

The easiest way to create your val list is using a comprehension:
val=[ [i,0] for i in range(1,5) ]

Hope this helps,
Denes.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to