Geek Culture
Published in

Geek Culture

Python: Context Managers are Simple

When you should use them

Say, you own a hotel. And you want to make sure that no lights are on when the rooms are empty. You tell your guests: please, turn the lights off when you leave your room. But they keep forgetting that.

So, you hire a manager who takes care of this. Once this manager sees that the room is not being used anymore, he/she turns the lights…

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

Which Programming Language should YOU pick?

READ/DOWNLOAD%) Analysis and Design of Energy Systems FULL BOOK PDF & FULL AUDIOBOOK

Introduction to HTML Tables

ARP Spoofer with Python and Scapy — Part 2

Serverless CICD Pipeline to Delivery Apps to AWS Fargate — A Serverless Container Platform

Missing Terminal on Windows?

WSL2 Setup For Distributing To IaC Developers — Ansible Focus

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Timur Bakibayev

Timur Bakibayev

Professor, Ph.D. in CS, Almaty Management University

More from Medium

How to Use Python getattr() Method

Solved In One Line Of Python — 3 Python Pattern Printing Practices

Memory Management in Python: Garbage Collector