In Python, sometimes you will see this syntax
Then you ask yourself, why I have to use this
with syntax ? What runs inside that statement ?
Here is how it works, it’s called Context Managers in object
You can define context managers for a class of object to make sure some logic runs correctly without forgeting
Enter the room !
So, when you start using
with keyword on a object, it runs
__enter__ method, when everything inside
with block is runned,
__exit__ will be called !
It’s cool feature of Python !