Skip to main content

the most readable decorators you've ever seen

Project description

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.

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

heckorator-0.1.5.tar.gz (56.4 kB view details)

Uploaded Source

Built Distribution

heckorator-0.1.5-py3-none-any.whl (58.2 kB view details)

Uploaded Python 3

File details

Details for the file heckorator-0.1.5.tar.gz.

File metadata

  • Download URL: heckorator-0.1.5.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/24.0.0

File hashes

Hashes for heckorator-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3a31d21a80adc9aff50e9b6e6f99e59ed3c5bc0cd4dde5fbb2e042b592935cb1
MD5 e0c4d409251d84ea9056516665e89627
BLAKE2b-256 c244e6bb5e409f40b9926cac55bfef87f8096d2f74874d88e551259bc9c63ef1

See more details on using hashes here.

File details

Details for the file heckorator-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: heckorator-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 58.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/24.0.0

File hashes

Hashes for heckorator-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 957a0a1055d30388d02bf70e5d355fc705c47a94ea5592dde4aa7d608baf646a
MD5 f1efdf0dd9e2b6ea6bb830b13a65d9be
BLAKE2b-256 27e4fa90192bdb6a66de05904fe929d6e86bcd7eb1d4495a044354fb1d799b7f

See more details on using hashes here.

Supported by

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