with statement in Python is a quite useful tool for properly managing external resources in your programs. It allows you to take advantage of existing context managers to automatically handle the setup and teardown phases whenever you’re dealing with external resources or with operations that require those phases.
What’s a context manager? It’s a block of code that has side effects upon entering and exiting. The context management protocol allows you to create your own context managers so you can customize the way you deal with system resources.
In this video course, you’ll learn:
- How context managers work
- Some common context managers in the Python standard library
- How to write a custom context manager
With this knowledge, you’ll write more expressive code and avoid resource leaks in your programs.
- 7 Lessons
- Video Subtitles and Full Transcript
- 2 Downloadable Resources
- Accompanying Text-Based Tutorial
- Q&A With Python Experts: Ask a Question
- Certificate of Completion