etuples

0.3.10 · active · verified Sat Apr 11

etuples is a Python library that provides S-expression emulation using tuple-like objects. It allows for the creation of functional expression trees that can be explicitly evaluated. The library is currently at version 0.3.10 and has an active development status with several releases in the past year.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create basic S-expression-like tuples using `etuple`, how to evaluate them, and how to use `etuplize` to convert a regular callable into an expression-tuple factory.

from operator import add
from etuples import etuple, etuplize

# Create an expression tuple
et = etuple(add, 1, 2)
print(f"Expression: {et}")

# Evaluate the expression
result = et.eval()
print(f"Result of evaluation: {result}")

# etuplize can convert callables into etuples
def my_func(a, b):
    return a * b

et_func = etuplize(my_func)
et_expression = et_func(3, 4)
print(f"Et_expression: {et_expression}")
print(f"Result of et_expression: {et_expression.eval()}")

view raw JSON →