heckorator - the most readable decorators you've ever seen
Also see my blogpost on this
Python 3.9 relaxed the syntax requirements for decorator expressions, allowing arbitrary expressions to be placed inside decorators. Some worried users raised some concerns about the readability of such code. I think code readability matters a lot, which is why I created this library, heckorator! Its purpose is to make decorators a heck of a lot more readable!
This initially unreadable piece of code:
x = [Button(position=i) for i in range(10)]
@x[0].on
def handle_click():
print("First button clicked!")
... is transformed into the massively readable:
from heckorator import _
x = [Button(position=i) for i in range(10)]
@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_
@_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._@_
@_._._._._._._._._@_@_@_._._._._._._._._._@_@_@_._._._._._._._._._._._._._._._._._._._._@_
@_._._._._._._._._@_._._._._._@_@_@_._._._._._@_._._._._._._._._._._._._._._._._._._._._@_
@_._._._._._._._._@_._._._._@_._._._@_._._._._@_._._._._._._._._._._._._._._._._._._._._@_
@_._@_._._._@_._._@_._._._._@_._._._@_._._._._@_._._._._._._._._._@_@_@_._._@_@_@_@_._._@_
@_._._@_._@_._._._@_._._._._@_._@_._@_._._._._@_._._._._._._._._@_._._._@_._@_._._._@_._@_
@_._._._@_._._._._@_._._._._@_._@_._@_._._._._@_._._._._._._._._@_._._._@_._@_._._._@_._@_
@_._._._@_._._._._@_._._._._@_._._._@_._._._._@_._._._._._._._._@_._._._@_._@_._._._@_._@_
@_._._@_._@_._._._@_._._._._@_._._._@_._._._._@_._._._@_@_._._._@_._._._@_._@_._._._@_._@_
@_._@_._._._@_._._@_._._._._._@_@_@_._._._._._@_._._._@_@_._._._._@_@_@_._._@_._._._@_._@_
@_._._._._._._._._@_._._._._._._._._._._._._._@_._._._._._._._._._._._._._._._._._._._._@_
@_._._._._._._._._@_@_@_._._._._._._._._._@_@_@_._._._._._._._._._._._._._._._._._._._._@_
@_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._@_
@_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._@_
@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_
def handle_click():
print("First button clicked!")
Yippee!
Why on earth would I want to do this
Self-explanatory, next question
Okay then but how do I use it
First, go get that thang:
pip install heckorator
Stick this before your code:
from heckorator import _
# Optionally customize font
# _.font("path/to/font/file")
And then stretch your pixel art muscles! (.....or you can use python3 -m heckorator generate to generate the pixel art from normal text.... but that's LAME!)
heckorator parses the pixel data of decorators as a string of characters based on a font file which can be specified by the user. By default, it uses the Cozette font.
Oh, and do keep in mind, you have to put a border around your decorators! And separate each row and column of text with a gap of 1 empty pixel! This just makes it cleaner and easier to read 😄 You care about readability, right?
What caused you to make this wtf
The noble search for clean code. I may also be bedridden with a cold, but that is only tangential.
Licensing acknowledgements etc etc you know the drill go have fun girlies
See the LICENSE file. The heckorator library is licensed under MIT. The Cozette font is licensed under MIT. Thanks to the qwdies in the QWD discord server for helping me look for nice fonts.
Metadata
Release files for heckorator 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| heckorator-0.1.5.tar.gz | 56.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| heckorator-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 114.6 kB
Release files / heckorator-0.1.5.tar.gz
| Download URL | heckorator-0.1.5.tar.gz |
|---|---|
| Size | 56.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a31d21a80adc9aff50e9b6e6f99e59ed3c5bc0cd4dde5fbb2e042b592935cb1
|
|
BLAKE2b-256 checksum How to use checksums |
c244e6bb5e409f40b9926cac55bfef87f8096d2f74874d88e551259bc9c63ef1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.7 Darwin/24.0.0
|
Release files / heckorator-0.1.5-py3-none-any.whl
| Download URL | heckorator-0.1.5-py3-none-any.whl |
|---|---|
| Size | 58.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
957a0a1055d30388d02bf70e5d355fc705c47a94ea5592dde4aa7d608baf646a
|
|
BLAKE2b-256 checksum How to use checksums |
27e4fa90192bdb6a66de05904fe929d6e86bcd7eb1d4495a044354fb1d799b7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.7 Darwin/24.0.0
|