python: conditional context and ExitStack (intermediate) anthony explains
HTML-код
- Опубликовано: 16 сен 2024
- today I talk about `ExitStack` and a few uses of it: conditional contexts, variable contexts
- context managers the hard way: • with + context manager...
- context managers the easy way: • with + context manager...
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/aso...
stream github: github.com/ant...
I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
The third option is very neat. I hope I'll remember it when I'll need it.
So far I've been "writing" to multiple outputs only when using logging with multiple handlers.
Whoa. I can use this to also open multiple files to write into. Brilliant. Thanks Anthony.
indeed! it's pretty great
If i leave a file open, does it automatically get freed once my python process ends, at least on linux?
yes, but it might not be in the state you expect -- unflushed buffers, etc. (same on windows)