Fundamentals 5 min read

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.

Java Tech Enthusiast
Java Tech Enthusiast
Java Tech Enthusiast
Bython: Add Braces to Python with a Simple Preprocessor

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 bython

Usage

Run a Bython program: bython source.by arg1 arg2 ... Show help and options:

bython -h
man bython

Convert 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.

Bython example
Bython example
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIPythonInstallationPreprocessorindentationbracesBython
Java Tech Enthusiast
Written by

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!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.