Updating sources list Couples chat

22 Feb

It is crucial to appreciate this difference between modifying an object via an object reference, and overwriting an object reference. We can use it to verify our earlier observations about objects.First we create a list containing several copies of the same object, and demonstrate that they are not only identical according to This reveals that the second item of the list has a distinct identifier.To understand what is going on here, we need to know how lists are stored in the computer's memory.In 4.1, we see that a list object wasn't changed, and is still referenced from two places in our nested list of lists.

You should make sure that when you write Python code in a file, you avoid tabs for indentation, since these can be misinterpreted by different text editors and the indentation can be messed up.

When we print a tuple, the parentheses are always displayed.

By using tuples in this way, we are implicitly aggregating items together.

Assignment always copies the value of an expression, but a value is not always what you might expect it to be.

In particular, the "value" of a structured object such as a list is actually just a does not copy the contents of the variable, only its "object reference".