Skip to main content

Yet Another Bython (braced Python) Implementation

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yabi_bython-0.9.3.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yabi_bython-0.9.3-py2.py3-none-any.whl (10.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file yabi_bython-0.9.3.tar.gz.

File metadata

  • Download URL: yabi_bython-0.9.3.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yabi_bython-0.9.3.tar.gz
Algorithm Hash digest
SHA256 fe6fc8b27c81ae33ea149a2fc02b2a8024438f2931ecff5ca14397492b0a77b9
MD5 0fd8a94d1870cf5e7cb0adeb49623f78
BLAKE2b-256 05d69cb3896de77ee7213531d3f5a2e8ae718efa30e8d9f0010c5d19c48fda90

See more details on using hashes here.

Provenance

The following attestation bundles were made for yabi_bython-0.9.3.tar.gz:

Publisher: release.yml on solaluset/yabi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yabi_bython-0.9.3-py2.py3-none-any.whl.

File metadata

  • Download URL: yabi_bython-0.9.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yabi_bython-0.9.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 49c8755a76945b3a614d6d29b34800fcd8f6226e2fd1224190f84b0f87588949
MD5 4927fc35c51afd8af49c30dfe528a0d2
BLAKE2b-256 aaabf821f9c384d7b7aea9e928db03da1c013813553943aff70fb5798fb4e7af

See more details on using hashes here.

Provenance

The following attestation bundles were made for yabi_bython-0.9.3-py2.py3-none-any.whl:

Publisher: release.yml on solaluset/yabi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page