Skip to content

Python interface

Patrick Hammer edited this page Jan 22, 2026 · 2 revisions

The Python interface ./python/petta.py can be used as follows:

from sexpdata import loads
from petta import *

metta = PeTTa()
wu = metta.process_metta_string("!(hello \"world\" 1.0 1)")[0]
print(loads(wu))

#Output:
#[Symbol('hello'), 'world', 1.0, 1]

We used sexpdata here to parse the returned S-expression string to Python datastructure (obtained via pip install sexpdata)

Clone this wiki locally