Python comes with many handy tools that can make our lives as developers or sysadmins easier. These tools are in the form of modules and libraries that are also executable. Many of these tools are known, but not all are as well known as they should be. I will mention a few useful tools that I have found in this post. How to write an executable Python script First, for beginners, a quick introduction to how to write executable scripts in Python.

Context Managers are one of the core language features that make Python unique. The with statement allows developers to write a common programming pattern in a concise and readable way. The following indented block gives a visual cue and make understanding the code easier. Understanding Context Managers is key to understanding the idea of Pythonic code.

Context Managers are usually used for allocation and releasing of resources, but that is not their only use-case. They are useful for factoring out common setup and teardown code, or any pair of operations that need to be performed before or after a procedure.

In this article, I will present some interesting real-world examples of their use, and hopefully encourage budding Pythonistas to explore them.