LangPy Usage Guide

Learn how to use LangPy to write Python code in your native language using natural language keywords

Installation

Requires Python 3.10 or higher

pip install langpy

Basic Usage

Execute LangPy files directly

Create a file with the appropriate extension (.pyes for Spanish, .pypt for Portuguese, .pyfr for French) and run it with the langpy command.

# hello.pyes
definir main():
    nombre = "World"
    imprimir(f"Hello {nombre}!")

main()
langpy hello.pyes

Supported Languages

Language is determined by file extension only

  • Spanish: .pyes extension
  • Portuguese: .pypt extension
  • French: .pyfr extension

Transpile to Python

Convert LangPy files to standard Python files

Generate .py files that can be executed with standard Python interpreter.

langpy --transpile script.pyes

This creates a .py file with the same name as your source file

LangPy automatically transpiles all imported modules that have the corresponding language extension, creating .py files in the same directory as their LangPy equivalents.

# If main.pyes imports utils/operations.pyes:
# main.pyes → main.py
# utils/operations.pyes → utils/operations.py

CLI Flags Reference

--transpile

Converts LangPy file to standard Python without executing it.

langpy --transpile script.pyes

--force

Forces overwrite of existing .py files during transpilation. Must be used with --transpile.

langpy --transpile --force script.pyes

--help

Shows help information and available commands.

langpy --help

--version

Displays the installed LangPy version.

langpy --version

Working with Libraries

LangPy is 100% compatible with Python libraries

You can import and use any Python library or create local modules using LangPy syntax.

# utils/operations.pyes
definir suma(a, b):
    retornar a + b
# main.pyes
desde utils.operations importar suma
importar numpy como np

definir analizar_datos():
    resultado = suma(10, 5)
    datos = np.array([1, 2, 3, 4, 5])
    imprimir(f"Media: {np.mean(datos)}")

analizar_datos()
langpy main.pyes

How It Works

LangPy is a lexical transpiler that translates only keywords to Python, leaving everything else unchanged.

  1. Reads your .pyes/.pypt/.pyfr file
  2. Tokenizes using Python's stdlib tokenizer
  3. Replaces keyword tokens with Python equivalents
  4. Untokenizes back to Python code
  5. Executes with standard Python VM

Zero runtime overhead - executes as native Python with no performance penalty