Managing (aka. cleaning up) a nested dictionary in Python

We are storing configurations. Let’s assume we are working on a store and we want to save prices for different products. But there are a set of configurations we have to consider1: We are working over multiple countries. Every country has got some locations. Every location has a set of articles. For an article, I might have multiple sizes. Finally, for every size I have got prices. Now let’s say that we want to store all of that in a Python dictionary. Luckily, the set of options is not too large, so that we can easily store it in a nested dictionary, which looks something like that: ...

November 1, 2025 · 5 min · 955 words · Chris Pratl

Removing a password from a PDF - Python version

I transferred a job that now does not run in Node-Red any more, but in Python.

October 20, 2025 · 3 min · 444 words · Chris Pratl

Setting up pyenv for Virtual environment management

I learned about PyEnv and want to write down the most important learnings.

October 12, 2025 · 3 min · 490 words · Chris Pratl

Commercial rounding in Python

As it turns out, Python does not do commercial rounding. What is commercial rounding? For most digits, the direction of rounding is clear. There are some special cases though: Do I round $0.5$ to $0$ or to $1$? In commercial rounding, this “$0.5$” problem is solved by “rounding away from zero”, meaning: For positive numbers, round up; for negative numbers, round down. This makes perfect sense for a mathematician, but others might need examples, so here are some1: ...

September 30, 2025 · 2 min · 356 words · Chris Pratl

Counter-intuitive negative timedeltas in Python

I learned about negative timedeltas in Python’s datetime library and find it a bit counterintuitive.

August 31, 2025 · 2 min · 305 words · Chris Pratl

Drawing a countdown clock in SVG

I created my first SVG image by hand and want to write down what I learned on the way.

May 27, 2025 · 10 min · 1950 words · Chris Pratl

Python: Nested with Statements

I can easily write nested with statements in Python.

February 7, 2025 · 1 min · 114 words · Chris Pratl

Check if a string is a web URL via a regular expression

I want to check if a string is an URL and created a regular expression for that.

July 9, 2024 · 2 min · 420 words · Chris Pratl

Algorithm: Reading multiple JSON objects from a file

I receive a file with multiple JSON objects in a row. I want to decode them one after another.

October 5, 2023 · 4 min · 846 words · Chris Pratl

My Jupyter Notebook Setup

Documentation how I have setup my Jupyter Notebook Setup.

October 3, 2023 · 4 min · 646 words · Chris Pratl

Poll data from an Azure Storage Account Blob into a Python Azure Function

How to read a JSON document from an Azure (Blob) Storage Account and use that in an Azure Function.

September 11, 2023 · 1 min · 160 words · Chris Pratl

Deploy a Python FastAPI app on Azure App Services

I want to deploy a FastAPI app via Azure App Services.

April 19, 2023 · 2 min · 244 words · Chris Pratl

Python's walrus operator in list comprehension

I found a first use case where I actually need Python’s walrus operator!

April 5, 2023 · 2 min · 292 words · Chris Pratl

Timezones are important!

I failed with time zones.

April 3, 2023 · 1 min · 116 words · Chris Pratl

Confluent Kafka Python Consumer: Reported Offsets

In edge cases, a consumer does not report the offsets I assumed he would report.

March 3, 2023 · 5 min · 940 words · Chris Pratl