TEL¶
TEL, the Tesserae Expression Language, is a small, safe expression language and a Python library that parses and evaluates it. It lets plain YAML (or Python code) express conditions, repeaters and live values, without giving the text any way out of the sandbox.
Status
Alpha: package 0.2.0, language version 0.1. The API may change before 1.0, and a minor version
may break it (versioning). The package is tesserae-el on PyPI and is imported
as tess_el (it was tel until 0.1.1).
Install¶
TEL needs Python 3.14 or later and has no dependencies:
pip install tesserae-el
A first expression¶
import tess_el
expr = tess_el.compile_expression("'low' if battery < 20 else f'{battery}%'", language="0.1")
expr.evaluate(tess_el.MapScope({"battery": 63})) # '63%'
expr.evaluate(tess_el.MapScope({"battery": 12})) # 'low'
A conditional can also be written cond ? a : b. In YAML, quote a value that contains :, since a
colon followed by a space ends a plain scalar.
Where to read next¶
| If you want | Read |
|---|---|
| The language and the API, section by section | Language specification |
| What every error code means | Error codes |
| What is protected, how it is checked, what is not guaranteed | Security review |
| Why a choice was made | Decisions |
| How fast it is, and against what | Benchmarks |
What the reference cases from expr.py pin |
Reference cases |
| How package and language versions work | Versioning |
The source, the issues and the changelog are on GitHub; the package is on PyPI.