Python Tutorial: Context Managers – Efficiently Managing Resources


Video is ready, Click Here to View ×

In this Python Programming Tutorial, we will be learning how to use context managers to properly manage resources. Context Managers are great for when we need to setup or teardown some resources during use. So these can be used for: open and closing files, opening and closing database connections, acquiring and releasing locks, and much much more. Let’s get started…

The code from this video can be found…

31 thoughts on “Python Tutorial: Context Managers – Efficiently Managing Resources

  1. @CoreySchafer after several months of watching videos on the internet and going through various online training including ones I purchased, I can safely say this channel and specifically Corey Schafer has the best Python training videos on YouTube and perhaps on the entire internet! Thank you very much for taking the time to make these videos and share them with all of us! I find myself repeatedly revisiting your videos as an excellent training reference, well done! I am of course subscribed with notifications turned on and thumbs up! I wish I could give this channel a million thumbs up! I let all the videos play to the end on both my browser and on Chromecast and I hope that boosts your statistics and views, you certainly deserve credit for excellent training and making the Internet a better place for us all! I will be joining your Patreon and helping to support this channel, something I do not often do with limited funding and only reserve the very best content which this certainly is!

  2. I am pretty thanks for this video and your videos. No doubt, just I need to try myself. And I would like to show the sending without and with attachment files in Python. Hope you are doing fine.

  3. Corey, thank you for posting these tuts on Python. I've found them all so interesting. I really enjoyed understanding how context managers work and thanks to your video on them I've already made use of one in a project. Thanks again, buddy. They're much appreciated.

  4. Hey Corey. Excellent video. Your channel is the best on YT in my humble opinion. Can you create a series of videos concerning data structures and algorithms for technical interviews? I think you’d be awesome at it since your teaching ability is 10 out of 10 😄

  5. hi corey, i love your videos so much, can i just make one request and i hope you take it into consideration
    it will help me and alot of people too
    can you make 3 playlists about python data scientists libraries(pandas,matplotlib,numpy)
    it will be very helpful
    thank you in advance and keep up the good work

  6. Great video! Thanks! One question… In the change_dir() example, if there is an error, will it have the original directory in cwd so it can chdir back to it in the finally section?

Leave a Reply

Your email address will not be published. Required fields are marked *