Python Interop
Kedi is designed to work seamlessly with Python. You can execute Python code directly within your Kedi files.
Inline Expressions
Use backticks `...` to evaluate a Python expression inline.
You can also use them in template strings:
Multiline Blocks
For more complex logic, use triple backticks ....
[fib_sequence: list[int]] = ```
a, b = 0, 1
result = []
for _ in range(10):
result.append(a)
a, b = b, a + b
return result
```
Preamble (Imports)
You can place Python imports and helper functions at the top of your file (or anywhere, really, but top is best practice).
```
import math
import random
def calculate_area(radius):
return math.pi * radius * radius
```
[area] = `calculate_area(5)`
= Area is <area>
Calling Kedi from Python
You can also call compiled Kedi procedures from within the Python blocks.