Quick Recap
- An assignment to a global variable in a local scope creates a new variable in the local scope. To actually modify the variable outside the local scope, you’ll have to use either the
global
or thenonlocal
keyword. - Multiplication of lists containing mutable items creates multiple references to the same mutable object under the hood.
- The
del x
keyword’s behavior is to decrease the reference count ofx
, and the dunder method__del__
is only invoked by Python when the object’s reference count reaches zero.
Get hands-on with 1400+ tech skills courses.