4 ms·
The idea is you can register a custom file encoding, analogous to built-in file encodings like utf-8, and use it to transform the source file before python load
by JackC 2y ago
The idea is you can register a custom file encoding, analogous to built-in file encodings like utf-8, and use it to transform the source file before python loads it. An example is pyxl, kind of like jsx, where you put `# coding: pyxl` at the top and then it will transform bare `<html>` in the python file into calls to a template builder: https://github.com/gvanrossum/pyxl3 https://github.com/gvanrossum/pyxl3
Incidentally this turns out to be super hard to search for without asking an LLM, since "python coding" is so overloaded, and using the feature this way is intentionally undocumented because it's not really what it's for, and not something I think most python users really want to encourage. So, forbidden python knowledge!
- kevindamm 2y agoIt's specified in PEP 263 [0] which pulls up easier on search if you quote it and include the typical "special comment symbol" -*- around it. [0]: https://peps.python.org/pep-0263/ https://peps.python.org/pep-0263/