If you code, you probably use a terminal emulator. Maybe you build docker images with
docker build, explore a database with
mysql or manage cloud infrastructure with
Sometimes you want to use these utilities in a Python script. This can be done using the
subprocess module. For example,
docker run hello-world
This works just fine, but there is another way. The Docker SDK for Python achieves the same result with:
And it’s not just Docker:
Why is it that I can move the mouse pointer on my computer while watching a movie? Or open an email while on a video call? Even in the days when CPUs were single core, computers were seemingly able to manage all sorts of tasks at the same time. Yet every task — even just moving the mouse — requires some CPU time, and single core CPUs can only do one thing at a time.
The answer is that CPUs are so unimaginably fast that even though two things can’t actually happen at the same time, it is possible to give the impression that they do. …
At school most of us study three measures of centrality for dataset: the mean, the median and the mode. Given the dataset 1, 1, 4, 12, 20:
When I learned about the mean, it needed no further explanation. As a measure of the centre of a dataset, it felt intuitive.
The motivations behind the median and the mode were more hazy. I understood them well enough for year end tests, but I wasn’t convinced of their utility in the real world. The trouble with the median is that if I change that 20 to 2,000, the median wouldn’t even care. This felt most unsatisfactory. The mode is even worse. It doesn’t tell you anything about the dataset as a whole — it just obsesses over one element that happens to occur more than the others. …
A great thing about Python is how easy it is to throw together a quick automation script. It is empowering to be able to build a tool tailored to whatever task you happen to have.
Many developers write such scripts for their personal use, but sometimes it is desirable to share these: distribute them to your team, to everyone in your organisation or even open source them.
But there are some difficulties associated with this: