Ever wanted to use braces instead of indentation in Python? No? Well, it's possible now!
pip install yabi-bython# run file
yabi file.by
# run module
yabi -m module
# run interactive console
yabi
# run code from command line
yabi -c "import os; try { os.remove('/') } except { print('Bruh') }"Run yabi --help to see other options.
- Doesn't have problems with dicts
- Has full
importsupport (any.byfile can be imported) - Has
.pycsupport (code is cached after translation)
It can have bugs though, I'd be glad if you opened an issue in case you encounter one.
If your condition contains { or lambda, remember to parenthesise it:
# Wrong
if x := {a for a in range(n)} { print("Hello") }
# Correct
if (x := {a for a in range(n)}) { print("Hello") }Braces and semicolons allow to make any code a one-liner. But, like, why would you do that?
In case braces aren't enough for you, there's an option to enable C-style preprocessing.
You can do so by passing --enable-preprocessing as argument to YABI or putting #pragma pypp on into the code.
YABI heavily relies on PWCP after all.
You don't need to convert anything because .py files can be imported into .by.
YABI provides yabi-convert in case you still want to convert.
The output may be a little weird but should still be correct.
yabi-convert something.py > something.byInspired by https://github.com/mathialo/bython and my friend ByThon.