Welcome to the second post from the GRASP series. GRASP stands for General Responsibility Assignment Software Principles. It is a great aid for Object-Oriented Design (but not really exclusive for OOP!). It is all about putting responsibilities in code structures such as classes/methods/modules in such a way it “makes sense”. The challenge A couple of […]
Author: Sebastian

Where to put all your utils in Python projects?
This is a follow-up post to Stop naming your Python modules “utils”. This time, let’s see different options on organizing utility code. What is utility code? It is code that is created as a side effect when working on features but does not belong to where they are implemented. It still is necessary or convenient […]

The disenchantment of Python web frameworks
tl;dr Popular Python web frameworks have less significant differences than it appears. Then, there’s Django which makes all competition look micro. Even given the rising popularity of FastAPI, I strongly believe there’s room for at least one another big framework. Comparing Python frameworks Back when I worked for a software house – STX Next I […]
GRASP Controller pattern in Python
Welcome to the first post from the GRASP series. GRASP stands for General Responsibility Assignment Software Principles. It is a great aid for Object-Oriented Design (but not really exclusive for OOP!). It is all about putting responsibilities in code structures such as classes/methods/modules in such a way it “makes sense”. Controller – what is it? […]
Custom exceptions in Python – how and what for?
Exceptions are a standard way of signalling errors in Python. If you have ever written some code in this language, I bet you saw at least a couple of them. 🙂 Python has quite a few built-in exception classes for all occasions. For example, there’s ZeroDivisionError raised when you try to divide by zero. Or […]
Python Object-Oriented Programming fundamentals and the most common mistake
The problem One antipattern I see over and over again in OOP Python code (e.g. with service layers in Django) is mutating attributes from the outside of a given object: What’s wrong with that? Surprisingly many things. First of all, it’s pretty complex logic that touches the guts of an Auction. It does not only […]
Meet python-mockito and leave built-in mock & patch behind
Batteries included can give you headache unittest.mock.[Magic]Mock and unittest.patch are powerful utilities in the standard library that can help us in writing tests. Although it is easy to start using them, there are several pitfalls waiting for unaware beginners. For example, forgetting about optional spec or spec_set can give us green tests for code that […]
How to use code coverage in Python with pytest?
Basics What is code coverage? In the simplest words, code coverage is a measure of exhaustiveness of a test suite. 100% code coverage means that a system is fully tested. Why bother about code coverage in Python? Theoretically, the higher code coverage is, the fewer defects a system has. Of course, tests are not enough […]
How to implement and use Command Bus in Python with Injector?
What’s a command bus? Command Bus is an incarnation of Mediator design pattern. It provides a way to decouple the code structure that sends a command to its receiver. It becomes handy with CQRS implementation with regard to the write stack. Commands are implemented as immutable data structures. It can be done with e.g. dataclasses […]

Python & the Clean Architecture in 2021
It’s been almost 3 years since I used the Clean Architecture in production for the first time. I made it to quite a few conferences to talk about it (e.g. see Clean Architecture in Python talk from PyGotham 2018). Also, I wrote an article about the Clean Architecture that made it to RealPython.com newsletter. …but […]