Synt¤
Write Python with Python. Inspired by jennifer.
Synt is a library for developers to write elegant machine-generated Python code.
Installation¤
To install Synt, use your preferred package manager and add synt
to your dependencies, e.g. by pip:
Then, import Synt:
Overview¤
Synt creates a Python-based DSL for writing actual Python code.
Different from text-based template systems like Jinja, Synt allows you to construct Python code generator as-is:
Usage¤
Synt keeps most of Python's standard operations as-is. Currently, Synt only supports generating expressions, and statement generating is on the to-do list.
Typically, special syntax in Python can be used with alias methods with the same name. For example, the following example shows how to create a generator comprehension:
For full api documentation, see the Documentation page.