Skip to content

solaluset/yabi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YABI

Ever wanted to use braces instead of indentation in Python? No? Well, it's possible now!

Installing

pip install yabi-bython

Running

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

Is YABI better than other implementations?

  • Doesn't have problems with dicts
  • Has full import support (any .by file can be imported)
  • Has .pyc support (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") }

Perfect for one-liners

Braces and semicolons allow to make any code a one-liner. But, like, why would you do that?

C-style preprocessing?!

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.

Converting Python files

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

Acknowledgements

Inspired by https://github.com/mathialo/bython and my friend ByThon.

About

Yet Another Bython (braced Python) Implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages