Module (8%)
Section (14%)

It’s hard to imagine writing a piece of Python code that performs any kind of data processing without making use of variables. As variables are fundamental elements that allow us to cope with objects, let's talk in detail about variables and objects, and possible ways of copying them.

When you spot the following clause:

a_list = [ 1, 'New York', 100]

you should understand it in the following way:


Variable object


(Note that an assignment statement is being used, so evaluation of the right side of the clause takes precedence over the left side.)

  • At first, an object (a list in this example) is created in the computer's memory. Now the object has its identity;
  • then the object is populated with other objects. Now our object has a value;
  • finally a variable, which you should treat as a label or name binding, is created, and this label refers to a distinct place in the computer memory.