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 the nonlocal 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 of x, 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.