NiklasRosenstein / python-builddsl

A superset of the Python programming language with support for closures and multi-line lambdas

Home Page:https://niklasrosenstein.github.io/craftr-dsl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

builddsl

BuildDSL is (almost) a superset of the Python programming language that adds additional syntactical and semantical features that are strongly inspired by the Gradle DSL.

  • Multi-line lambdas
  • Closures with dynamic name resolution (optional feature)
  • Parentheses-less function calls (top-level only)
  • Optional comma separation in function arguments

Installation

$ pip install builddsl

The builddsl package requires at least Python 3.6.

Quickstart

import builddsl
from typing import Callable

def hello(get_name: Callable[[], str]) -> None:
    print("Hello", get_name())

context = builddsl.Context(
    target=builddsl.targets.mutable_mapping({"hello": hello}),
    closures_enabled=True,
)

context.exec("""
hello {
    return "World"
}
""")

# prints: "Hello, World"

Projects using BuildDSL

About

A superset of the Python programming language with support for closures and multi-line lambdas

https://niklasrosenstein.github.io/craftr-dsl/

License:MIT License


Languages

Language:Python 100.0%