It is because pv is a pointer to the memory that holds its list.

When you append pv to val, your appending the *reference* to pv.

So whenever you update pv, all references to pv also reflect these changes.

The reason that slicing pv with [:] works is because you are making a
copy of pv, and appending the copy into val.

The reason that pv = [i,0] works is because you assigning a new memory
reference to pv.

-Thadeus





On Mon, Jan 11, 2010 at 9:46 AM, DenesL <denes1...@yahoo.ca> wrote:
> e 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 cha
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to