Skip to content

Commit 3072975

Browse files
committed
Init
0 parents  commit 3072975

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# Common Expression Language (CEL)
3+
4+
The Common Expression Language (CEL) is a non-Turing complete language designed for simplicity,
5+
speed, and safety. CEL is primarily used for evaluating expressions in a variety of applications,
6+
such as policy evaluation, state machine transitions, and graph traversals.
7+
8+
This Python package wraps the Rust implementation [cel-interpreter](https://crates.io/crates/cel-interpreter).
9+
10+
Basic usage:
11+
12+
```python
13+
from cel import evaluate
14+
expression = "age > 21"
15+
result = evaluate(expression, {"age": 18})
16+
print(result) # False
17+
```
18+
19+
20+
## Command line interface
21+
22+
The package also provides a command line interface for evaluating CEL expressions:
23+
24+
```bash
25+
$ python -m cel '1 + 2'
26+
3
27+
```
28+
29+
30+
## Future work
31+
32+
Ability to add Python functions to the Context object:
33+
34+
```python
35+
from cel import evaluate, Context
36+
37+
def is_adult(age):
38+
return age > 21
39+
40+
context = Context()
41+
context.add_function("is_adult", is_adult)
42+
print(evaluate("is_adult(age)", {"age": 18}, context)) # False
43+
```

0 commit comments

Comments
 (0)