Python's contextlib is a HIDDEN GEM

Описание к видео Python's contextlib is a HIDDEN GEM

The purpose of contextlib is fairly evident by the name (unless you've never heard of context managers), but it has some really cool tools that I wanted to share! Plus, there's a really neat decorator trick you can achieve with it too!

00:00 - Intro
00:32 - Using @contextmanager to create context managers [1]
06:46 - Using closing to close contexts [2]
08:26 - Using suppress to suppress exceptions [3]
10:47 - Using redirect_stdout and redirect_stderr [4-5]
14:24 - Outro

[1] https://docs.python.org/3/library/con...
[2] https://docs.python.org/3/library/con...
[3] https://docs.python.org/3/library/con...
[4] https://docs.python.org/3/library/con...
[5] https://docs.python.org/3/library/con...



If you want to see more of me, join my Discord server!
  / discord  

I get a lot of people asking, so here's my setup!
• Visual Studio Code:    • My Visual Studio Code setup! (2024)  
• Terminal:    • Make your terminal look AMAZING  
• Desk/recording gear: https://kit.co/Carberra
• PC build: https://uk.pcpartpicker.com/list/TmzGYN



If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so.

#python #coding #howto

Комментарии

Информация по комментариям в разработке