Show HN: Serializable infix expressions and a Python evaluator

I had written a tiny Python utility for evaluating serializable infix expressions a couple of years ago (inspired by JsonLogic). Last week, I talked to an old colleague who was looking for something very identical so I thought I'd share it here.

Quick examples:

xpress.evaluate([[3, ">", 1], "and", [1, "<", 3]]) # True

rules = [["var:temp", "<", 110], "and", ["var:pie.filling", "==", "apple"]]

data = { "temp" : 100, "pie" : { "filling" : "apple" } }

xpress.evaluate(rules, data) # True

The original purpose was building a flexible query builder. Later, I also used it for expressing log routing conditions in our config file.

1 points sb13 2 years ago 0 comments

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton