From Python to Configurators
OptiKonf FlexCo October 15, 2026 #python #configurator #confiloxOne of our input languages is Python. In this article, we present how quickly you can go from code to a smart configurator.
PyDM is a subset of Python from which the Confilox platform automatically extracts smart configurators. The language supports:
- Choices
- Integer and floating-point inputs
- Text values
- Procedures
- Arbitrary variable reassignment and assignment
PyDM demonstrates a particularly useful feature of our platform: importing rule systems with linear dependencies. Successive questions do not need to be laboriously translated into new logic first; they can simply be transcribed as they are, one-to-one. Other formats, such as tables or proprietary data exports, can also be imported with ease.
An Example Configurator
Suppose a coffee machine retailer wants to define variants of its own product range. A configurator might look like this:
class CoffeeMachine:
def configure():
MachineType = choice("Portafilter", "Filter")
if MachineType == "Portafilter":
Grinder = choice("integrated", "external")
else:
Grinder = "external"This code is entered directly into our backend, which comes with a built-in code editor:

The configurator then looks like this in the preview provided by our interface. Of course, our API also lets you embed the configurator into virtually any other interface.

Instead of coffee machines, you can configure industrial machinery, vehicles, services, processes, and much more. Our platform places no limits on what you can build with it. For the sake of clarity, we'll focus here on everyday appliances — even these reveal a surprising degree of combinatorial complexity.
Increasing Complexity
The coffee retailer now wants to sell coffee varieties to go with each machine. They already offer two pre-ground varieties, as well as one variety that customers can grind themselves.
def coffee():
CoffeeVariety = choice("Bean There", "Portafilter Sensation", "Filter Fantastica")
if CoffeeVariety == "Portafilter Sensation":
GrindSize = "coarse"
Grinder = "none"
elif CoffeeVariety == "Filter Fantastica":
GrindSize = "fine"
Grinder = "none"These varieties are now incorporated into the rest of the configurator.
class CoffeeMachine:
def configure():
MachineType = choice("Portafilter", "Filter")
if MachineType == "Portafilter":
Grinder = choice("integrated", "external")
else:
Grinder = "external"
coffee()
if MachineType == "Filter":
assert GrindSize == "coarse"
elif MachineType == "Portafilter":
assert GrindSize == "fine"The retailer has an idea: when a filter machine is selected, the chosen coffee must have a coarse grind; otherwise, the water would never make it through the coffee. With a portafilter machine, which operates at higher pressure, it's exactly the opposite — the grind needs to be fine.
The Bean There variety is no longer mentioned anywhere in the code. So what happens when customers choose this coffee? Naturally, all possibilities remain available, and the generated configurations on the right still look exactly as expected:

Grinder Problems
External grinders turn out to be more complicated than expected. Some can grind only coarsely, others only finely, and only the really special ones can do both. No problem, though — the retailer simply adds a little more to the configurator:
class CoffeeMachine:
def coffee():
CoffeeVariety = choice("Bean There", "Portafilter Sensation", "Filter Fantastica")
if CoffeeVariety == "Portafilter Sensation":
GrindSize = "fine"
elif CoffeeVariety == "Filter Fantastica":
GrindSize = "coarse"
def grinder():
GrinderName = choice("The Coarse One", "The Fine Grinder", "MegaGrinder")
if GrinderName == "The Coarse One":
assert GrindSize == "coarse"
elif GrinderName == "The Fine Grinder":
assert GrindSize == "fine"
def configure():
MachineType = choice("Portafilter", "Filter")
if MachineType == "Portafilter":
Grinder = choice("integrated", "external")
else:
Grinder = "external"
coffee()
GrinderName = "No external grinder"
if Grinder == "external":
grinder()
if MachineType == "Filter":
assert GrindSize == "coarse"
elif MachineType == "Portafilter":
assert GrindSize == "fine" The retailer typically lists all possible variants in grinder and then narrows down the options. Here, we use assert statements because we don't want to override the customer's choice of coffee beans — we only want to restrict the available possibilities further. Otherwise, the choice of beans would make no difference; the grinder alone would determine the grind size.
A quick look at the configurator preview, still running in the background, confirms that everything continues to work as intended:

An integrated grinder is the other option, and of course, that still works as well:

Here we can immediately see how Confilox automatically extracts all the relationships, without any additional questions or explanations!
Pricing
Different products naturally come with different price tags. We offer specialized imports for data in proprietary formats, such as Excel price lists and similar sources. To keep things consistent here, though, we'll define the prices in PyDM itself. For this, we write another procedure:
def prices():
Price = 0
if MachineType == "Portafilter":
Price += 500
if Grinder == "integrated":
Price += 300
elif MachineType == "Filter":
Price += 100
if GrinderName == "The Coarse One":
Price += 150
elif GrinderName == "The Fine Grinder":
Price += 200
elif GrinderName == "MegaGrinder":
Price += 350
if CoffeeVariety == "Bean There":
Price += 30
elif CoffeeVariety == "Portafilter Sensation":
Price += 20
elif CoffeeVariety == "Filter Fantastica":
Price += 40A coffee machine with an integrated grinder costs more. The external grinders also come at different prices, as do the various coffee options.
Now, if a customer asks how to enjoy the Bean There variety for the lowest possible price, the retailer can find the answer in no time, thanks to Confilox's optimization feature:

Complete Example Code
class CoffeeMachine:
def coffee():
CoffeeVariety = choice("Bean There", "Portafilter Sensation", "Filter Fantastica")
if CoffeeVariety == "Portafilter Sensation":
GrindSize = "fine"
Grinder = "none"
elif CoffeeVariety == "Filter Fantastica":
GrindSize = "coarse"
Grinder = "none"
def grinder():
GrinderName = choice("The Coarse One", "The Fine Grinder", "MegaGrinder")
if GrinderName == "The Coarse One":
assert GrindSize == "coarse"
elif GrinderName == "The Fine Grinder":
assert GrindSize == "fine"
def prices():
Price = 0
if MachineType == "Portafilter":
Price += 500
if Grinder == "integrated":
Price += 300
elif MachineType == "Filter":
Price += 100
if GrinderName == "The Coarse One":
Price += 150
elif GrinderName == "The Fine Grinder":
Price += 200
elif GrinderName == "MegaGrinder":
Price += 350
def configure():
MachineType = choice("Portafilter", "Filter")
if MachineType == "Portafilter":
Grinder = choice("integrated", "external")
else:
Grinder = "external"
coffee()
GrinderName = "No external grinder"
if Grinder == "external":
grinder()
if MachineType == "Filter":
assert GrindSize == "coarse"
elif MachineType == "Portafilter":
assert GrindSize == "fine"
prices()Coding agents can of course work with this code, too, adding further properties without needing any prior knowledge of PyDM.
The configurator is available online and can be tried out at any time: Coffee Retailer Configurator.