Python allows a codec directive at the start of a file which allows for a hook to rewrite the content.
Here are some uses I've found of this in the wild using this github query.
- python-parsing-shenanigans - basic demonstration of the technique
- InlineC
- Pyxl4 - Embedding HTML in python
- Tilde - Supporting pattern matching
- future-fstrings - a package for supporting fstrings in older versions of Python 3.
- pythonql - embedding a LINQ like query language in Python
- dansk.py - translate Python keywords to Danish
- pandas-encoding - instead of typing out the string
pandas
use 🐼 - cursed-for - C style for loops in python
- interpy - Ruby style string interpolation
- pyeet - Scribble-like template language