PyCon Sweden 2021

Rules Rule (Creating and Using a Rules Engine)
2021-10-22 , Software

Live stream: https://youtu.be/Lsi1ZhmbNDc

Stuck in a deeply nested if...else when traversing the pyramid of doom, you pause for a minute to catch your breath. The program’s logic eludes you and it is getting increasingly tiresome to keep track of all the twists and turns of the various conditions and possible return values.

You start to dream a dream of a flattering flattening of all this code. A dream of refactoring this bewildering maze into an orderly space, devoid of surprising and unexpected behaviour. A space where things have their obvious place and purpose.

You decide that you just just might need to set some rules.

Enter the Rules Engine.


This talk introduces the concept of rules and rules engines as well as a way of implementing this in Python. Building on top of the initial, simple implementation, it is then further demonstrated how to expand it to handle additional use cases that goes beyond the basic aim of refactoring nested conditional constructs such as if...else, including parallel execution of your rules.

The talk is suitable for anyone using Python as the concepts are pedagogically introduced and at the same time the overarching concept is a powerful tool.

Lennart is one of Agical's experienced consultants, hailing from Stockholm, Sweden.

In addition to being a polyglot developer partial to dynamic programming languages such as Elixir, Ruby, and Python, he is also an avid mob programmer, excessive tea drinker, utter horse lover, and tabletop roleplaying game fanatic.

He is currently working as a developer and team coach at Funnel, sharing code concepts and puns in equal measures.