Python Tip #85 (of 365):

Think of variables as pointers.

When explaining your code in Python, be sure to disambiguate between the 2 types of change (assignments and mutations).

"Changing" a variable just changes which object that variable points to.

"Changing" an object mutates that object. Every reference to that object will "see" the change.

Many Python gotchas derive from the pointer nature of Python's variables.

https://pym.dev/2-types-change/

#Python #DailyPythonTip

Assignment vs. Mutation in Python

In Python, "change" can mean two different things. Assignment changes which object a variable points to. Mutation, changes the object itself.