Start here
Some Python bugs give no error. The code runs, the numbers look fine, and the numbers are wrong. Most of them come from one idea: how a name relates to the data it holds.
You already know these words from earlier chapters:
- A variable is a name that holds a value.
- A list keeps values in order. A tuple is a list that cannot change.
- A dict keeps values under keys. A set keeps each value once.
- A function is a block of code with a name. You call it to run it.
The examples use the same shop. The list `orders` holds six dicts, one for each order.
What you will learn
- A name points at an object. Two names can point at one object.
- Which objects can change (mutable) and which cannot (immutable).
- Why a function can change the data you gave it.
- The default argument bug that carries rows over from one call to the next.
- The difference between a shallow copy and a deep copy.
- The difference between `==` and `is`.
- Why a dict key must not change.
- (Optional) What a small function remembers about names outside it.
