If you were holding your breath, you can let it out now! Congratulations on completing this deep dive into scopes and closures in Python. By using the debugger Thonny, you’ve walked through a code snippet to better understand how scopes and closures work.
In this Code Conversation video course, you:
- Refactored code to use more descriptive names
- Learned about local and nonlocal scopes and how functions access variables
- Understood how scopes open and close through inner and outer function calls
You used your interpreter to dig into Python and inspect dunder objects to find out how Python handles and stores variables.
For more informaton on the concepts covered in this video course, you can check out:
- Martijn Peters on Scopes and Closures: Stack Overflow
- Namespaces and Scope in Python
- Python Scope & the LEGB Rule: Resolving Names in Your Code
- Data Model: Python Documentation
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
Christopher Conlon on May 31, 2022
Interesting for those who are curious about how Python works under the hood. Unlikely to be much use to those who are only interested in practical Python application building (but could be).
It is sort of like the difference between working inside the space station and strapping on the EVA suit and taking a look at or working on the space station itself. If you are out there tinkering around with the solar panels then you are working on something completely different from running experiments inside. However, the inside work is dependent on that outside work.
Also, it is fun to step outside on an Extra Vehicular Activity.