Bython: Add Braces to Python with a Simple Preprocessor
Bython is an open‑source Python preprocessor that lets you write Python code with curly braces instead of relying on indentation, offering easy installation via PyPI or source, full compatibility with the Python ecosystem, and straightforward command‑line usage.
What is Bython?
Bython is a preprocessor that allows writing Python code with C‑style curly braces. Files with the .by extension are translated into standard .py files with correct indentation before execution. It does not introduce a new language; the generated code runs on any Python interpreter and can use existing libraries such as NumPy, Matplotlib, and others.
Key features
Eliminates indentation‑related syntax errors; mixed tabs/spaces or copied code no longer cause immediate crashes.
Full compatibility with the Python ecosystem; no changes to third‑party packages are required.
Installation
From PyPI: sudo -H pip3 install bython From source:
git clone https://github.com/mathialo/bython.git
cd bython
sudo -H pip3 install .Uninstall:
sudo -H pip3 uninstall bythonUsage
Run a Bython program: bython source.by arg1 arg2 ... Show help and options:
bython -h
man bythonConvert an existing Python file to Bython syntax: py2by test.py This creates test.by from test.py.
How it works
The preprocessor reads a .by file, parses the brace‑delimited blocks, and emits a temporary .py file with proper indentation.
The generated file is then executed by the system Python interpreter, so a functional Python environment must be available.
Repository
Source code: https://github.com/mathialo/bython
Limitations
Bython is intended for experimentation or personal preference. Production code should follow standard Python indentation to maintain readability and community conventions.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
