A pluggable manager for syntax rewriting codecs
Project description
Yes, this is a joke. But I think it works? *rofl* A joke… that works…
Projects like Coconut and cursed-for offer new syntax on top of the standard Python syntax. They achieve this by preprocessing code of their customized form down to standard Python. One option for this preprocessing is to leverage the source code encoding features of Python. For example, specifying # coding: coconut, after some other setup, can enable Coconut syntax for that file. But, what if you need multiple of these syntax modifying encodings? That’s where shimtax comes in and let’s you apply multiple other encodings.
# coding: shimtax:cursed-for:coconut
for (i = 0; i < 10; i += 2):
i |> print
Given that each encoding is offering custom syntax that the others are presumably unaware of, expect many combinations to be order dependent or to simply not work. Those that simply operate on the code as a string are much more likely to be mixable. Those that parse the code via a Python syntax parser are likely to fail.
Setup
shimtax can be set to be automatically enabled using the CLI. This will insert a .pth file in the platlib directory returned by sysconfig.get_path("platlib"). That file will register the shimtax encoding so you don’t have to.
$ .venv/bin/shimtax register
The CLI can also remove the .pth file.
$ .venv/bin/shimtax unregister
If handling this yourself is preferred, you can use the registration helper function.
import shimtax
shimtax.register()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.