Transpiles Bython to Python
Project description
Bython
Python with braces. Because Python is awesome, but whitespace is awful.
Bython is a Python preprosessor which translates curly braces into indentation.
Key features
- Write Python using braces instead of whitespace, and use the transpiler to convert it to valid Python code
- Transpiles curly braces while keeping maps, fstrings, and curlies inside strings intact
- Allows for translation of
&&and||toandandor - Can optionally translate
trueandfalsetoTrueandFalse
Code example
myMap = {
"status": "awesome!"
}
def print_message(num_of_times) {
for i in range(num_of_times) {
print(f"Bython is {myMap["status"]}");
}
}
if __name__ == "__main__" {
print_message(10);
}
Installation
Install from pip
$ python -m pip install bython-prushton
Quick intro
Bython works by first translating Bython-files (required file ending: .by) into Python-files, and then using Python to run them. You therefore need a working installation of Python for Bython to work.
To run a Bython program, simply type
$ python -m bython-prushton source.by
to run source.by. If you want more details on how to run Bython files (flags, etc), type
$ python -m bython-prushton -h
To transpile an entire directory, run bython with the -o to specify the output directory, and -e to specify the entry point.
$ python -m bython-prushton -o dist -e main.py src
To transpile without running, omit the -e argument. You can also include -t to translate lowercase booleans to uppercase and null to None
$ python -m bython-prushton -o dist -t src
Contributing
Code
If you want to contribute, make sure to install
- Python
- Colorama
All source code is located in src
src/bython-prushton/bython.pyhandles the command line argumentssrc/bython-prushton/parser.pyhandles tokenizing and parsing filessrc/bython-prushton/py2by.pyparses python to bython and could use some help
testcases have two structures for testing the parser and the cli:
bython
|-<test name>
| |-src Bython code to convert
| |-expected_out.txt Expected out when running the bython
| |-info.json Info on how to run the test
| |-build/ Dir for transpiled python code
parser
|-<test name>
| |-main.by Bython code to convert<br>
| |-expected_out.txt Expected out when running the bython
| |-build/ Dir for transpiled python code
run make test to run bython tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bython_prushton-1.1.6.tar.gz.
File metadata
- Download URL: bython_prushton-1.1.6.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
316db76e4a955997432317d6f82d337779aec5acd7c19d0f9bc4544c45840f73
|
|
| MD5 |
5b4a2d4e74b15b410b7dfbbf57b89138
|
|
| BLAKE2b-256 |
6e5ed09594d4244e423ca06e90e54f73b9ecbeeb7e26a6421f11a4e690c2eced
|
File details
Details for the file bython_prushton-1.1.6-py3-none-any.whl.
File metadata
- Download URL: bython_prushton-1.1.6-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8d3cba2f092a982176726e3586b2e3c6ae4fbf79448cb4d3d6c2edc544b742a
|
|
| MD5 |
be6d89a978e4b170d2581329570acc02
|
|
| BLAKE2b-256 |
c1cfea072379d05c570e5bc557e67c3a8a8c563b0fcbf2874c669ffacf57356d
|