Exploring Scopes and Closures in Python
Have you been wondering how scopes and closures work in Python? Maybe you’ve just heard about object.__closure__
, and you’d like to figure out what exactly it does. In this Code Conversation video course, you’ll use the debugger Thonny to walk through some sample code and get a better understanding of scopes and closures in Python.
In this Code Conversation video course, you’ll:
- Clarify code by refactoring it with descriptive names
- Learn how functions access variables in local and nonlocal scopes
- Understand how inner and outer function calls open and close their own scopes
You’ll also take a deep dive into the inner workings of Python by inspecting dunder objects to find out how Python handles and stores variables.