What Python’s "with" statement really does (and why it matters)

Опубликовано: 06 Ноябрь 2023
на канале: Python and Pandas with Reuven Lerner
2,020
96

Get better at Python, one short lesson a week — my free Better Developers newsletter: https://lernerpython.com/become-a-bet...

You’ve probably used `with open(...) as f:` in Python. But what does the `with` statement really do behind the scenes?

In this video, I break down:
What the `with` statement actually triggers in Python
Why files need to be flushed and closed properly
How the context manager protocol (`__enter__` and `__exit__`) works
How to write your own context manager using a class
Why `with` is Python’s go-to tool for safe, predictable cleanup — from files to logs to database transactions

Whether you’ve used `with` a hundred times or never really thought about it, this video will give you a deeper understanding of how Python works — and how to use it more confidently.


На этой странице сайта вы можете посмотреть видео онлайн What Python’s "with" statement really does (and why it matters) длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Python and Pandas with Reuven Lerner 06 Ноябрь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 2,020 раз и оно понравилось 96 зрителям. Приятного просмотра!