Skip to main content

Write Python code using keywords in your native language

Project description

LangPy

Write Python in your native language 🌍

LangPy is a lexical layer over Python that lets you write code using keywords in human languages, without changing Python's behavior.

# ejemplo.pyes (Spanish)
definir saludar(nombre):
    si nombre == "Ana":
        imprimir("Hola Ana")
    sino:
        imprimir("Hola", nombre)

saludar("Luis")
$ langpy ejemplo.pyes
Hola Luis

Why LangPy?

LangPy makes Python more accessible to non-English speakers by allowing you to use natural language keywords while keeping everything else exactly the same.

What LangPy IS ✅

  • A lexical transpiler that translates keywords to Python
  • 100% compatible with Python libraries and tools
  • Zero runtime overhead - executes as native Python
  • Easy migration path back to pure Python

What LangPy is NOT ❌

  • NOT a new programming language
  • NOT a custom interpreter or VM
  • NOT translating error messages or APIs
  • NOT changing Python's semantics

If something crosses these boundaries, it's out of scope.

Quick Start

Installation

Requirements: Python 3.10+

pip install langpy

Your First Program

Create a file hello.pyes:

definir main():
    nombre = "World"
    imprimir(f"Hello {nombre}!")

main()

Run it:

langpy hello.pyes

That's it! LangPy transpiles your code to standard Python and executes it immediately.

Supported Languages

Language Extension Keywords Example
Spanish .pyes definir, si, sino, imprimir
Portuguese .pypt definir, se, senao, imprimir
French .pyfr definir, si, sinon, imprimer

The language is determined solely by the file extension. No flags or configuration needed.

Real-World Example

LangPy works seamlessly with local imports and external libraries.

operations.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"Suma: {resultado}")

    # Use any Python library
    datos = np.array([1, 2, 3, 4, 5])
    imprimir(f"Media: {np.mean(datos)}")

analizar_datos()

Run it:

langpy main.pyes

How It Works

.pyes / .pypt / .pyfr file
        ↓
tokenize (Python stdlib)
        ↓
keyword replacement
        ↓
untokenize
        ↓
execute with Python VM

Key Design Principles

  • Only NAME tokens are translated (keywords)
  • Strings and comments remain unchanged
  • Attribute names are preserved (obj.method)
  • No custom AST or parser
  • If Python can't tokenize it, neither can LangPy

CLI Usage

Execute directly

langpy script.pyes

Transpile to Python

langpy --transpile script.pyes

This generates standard .py files that you can run with python.

Force overwrite

langpy --transpile --force script.pyes

Get help

langpy --help
langpy --version

Project Status

Version: 0.1.3

  • ✅ Stable transpilation core
  • ✅ Language lexicons defined
  • ✅ Fully functional CLI
  • ✅ Comprehensive test suite
  • ✅ Clear project scope

Contributing

LangPy's lexicon system is modular, making it easy to add new languages without modifying the core. Want to add your language? We'd love to have you contribute!

License

MIT


Made with ❤️ for the global Python community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langpy-0.1.3.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langpy-0.1.3-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file langpy-0.1.3.tar.gz.

File metadata

  • Download URL: langpy-0.1.3.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for langpy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 77c0abffc714a2f8552c1a9832249314ca25228db2b3659cc289a04367a8787b
MD5 08ad2d921116f3fec4e17c91907d6e2e
BLAKE2b-256 a041bd26c7cc9d22bfdce5bd334c9d7fe949c3213dfb5557b846754898771b8d

See more details on using hashes here.

File details

Details for the file langpy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: langpy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for langpy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bd92c72af36673e8c318b948dcdcf755a047141f3c74efd566b9375aaed1a298
MD5 5afe351e3dfd66b8b5ad5c3aa3d18166
BLAKE2b-256 1395dbd3ffad0325fd23158a286f7f6e8484045cab3ce2f0af77d690d0d82a68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page