LangPy Usage Guide
Learn how to use LangPy to write Python code in your native language using natural language keywords
Verify Installation
Verify that LangPy is correctly installed by running the command without arguments.
langpy
If LangPy is correctly installed, you will see an info message
Basic Usage
Execute LangPy files directly
Create a file with the appropriate extension (.pyes for Spanish, .pypt for Portuguese, .pyfr for French) and execute it with the langpy command.
# hello.pyes
definir main():
nombre = "World"
imprimir(f"Hello {nombre}!")
main()langpy hello.pyes
Supported Languages
The language is determined solely by the file extension
- Spanish: .pyes extension - keywords like definir, si, para, imprimir
- Portuguese: .pypt extension - keywords like definir, se, para, imprimir
- French: .pyfr extension - keywords like definir, si, pour, imprimer
Execute Projects
LangPy supports project structures with __main__ entry point
Organize your code in directories and use __main__.pyes as the main entry point.
my_project/
├── __main__.pyes # Entry point
├── math.pyes # Local module
└── utils/
├── __init__.pyes
└── helpers.pyeslangpy my_project/
LangPy will automatically execute the __main__.pyes file from the directory
Transpile to Python
Convert LangPy files to standard Python files
Generate .py files that can be executed with the standard Python interpreter.
langpy transpile script.pyes
This creates a .py file with the same name next to your source file
LangPy automatically resolves and transpiles all local imported modules with the corresponding language extension, preserving directory structure.
# If main.pyes imports utils/math.pyes: # main.pyes → main.py # utils/math.pyes → utils/math.py
Transpile to Specific Directory
Generate Python files in a custom output directory
Use the --output flag to specify an output directory. LangPy will copy all necessary files preserving the structure.
langpy transpile main.pyes --output dist/ langpy transpile main.pyes -o dist/
Transpiles imported LangPy files and copies referenced vanilla .py files (excluding pip modules)
CLI Commands Reference
langpy <file>
Directly execute a LangPy file or project with __main__.pyes
langpy script.pyes langpy my_project/
langpy transpile
Convert LangPy files to standard Python. Automatically resolves local LangPy imports.
langpy transpile script.pyes
--output / -o
Specify output directory for transpilation. Preserves directory structure and copies referenced vanilla .py files.
langpy transpile script.pyes --output dist/ langpy transpile script.pyes -o dist/
--force / -f
Force overwrite of existing .py files during transpilation.
langpy transpile script.pyes --force langpy transpile script.pyes -f
--help
Display help information and available commands.
langpy --help
--version
Display 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.
# math.pyes
definir suma(a, b):
retornar a + b
definir resta(a, b):
retornar a - b# main.pyes
desde operations importar suma, resta
importar numpy como np
definir analizar_datos():
# Use your functions
resultado = suma(10, 5)
imprimir(f"Sum: {resultado}")
# Use any Python library
datos = np.array([1, 2, 3, 4, 5])
imprimir(f"Mean: {np.mean(datos)}")
analizar_datos()langpy main.pyes
How It Works
LangPy is a lexical transpiler that only translates keywords to Python, leaving everything else unchanged.
- Read your .pyes/.pypt/.pyfr file
- Tokenize using Python's standard library tokenizer
- Replace only NAME tokens with keywords (strings and comments remain unchanged)
- Untokenize back to valid Python code
- Execute with standard Python virtual machine
Zero runtime overhead - executes as native Python with no performance penalty