On Mon, Apr 19, 2021 at 8:16 PM Glenn Linderman <v+pyt...@g.nevcal.com> wrote:
> On 4/19/2021 12:44 PM, Guido van Rossum wrote: > > We had a similar thing at Dropbox, where `# coding: pyxl` would enable > > a preprocessor that allowed HTML embedded in the Python code. It > > translated this to function calls and string literals. > > > > There were however several drawbacks: > > > > - Installing the codec is a bit tricky, and if you don't have it the > > code can't run > > - Other tooling won't know about the new syntax (someone went through > > heroic efforts to write a PyCharm extension for pyxl but it got stale > > very quickly) > > - The codec slows down the import process > > - Keeping line numbers accurate in the codec is painful > > - Occasionally, when debugging mysteries, you end up needing to see > > the source code after preprocessing, which requires yet another custom > > tool > > > > In the end the project was withdrawn and we switched to more > > mainstream templating solutions. > > > > I suspect that many of the issues with pyxl would also plague using > > this approach as a way to customize typing syntax, and I don't think > > it would be an improvement over the status quo. > > > How does this "similar thing" compare to the recently announced imphook > module? > For one, pyxl is a better name. :-) Seriously, as long as the purpose is to allow using a different grammar (for part of the file) that is then transpiled to proper Python, all but the first issue apply exactly the same. Getting the hook to run (my first bullet) actually sounds *more* complicated, because you have to include code in your `__main__` module that installs the hook(s). But I have zero experience with imphook, I just skimmed its PyPI home page, which has an example that calls ``` imphook.add_import_hook(hook, (".conf",)) ``` -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/EJOEHORIVSGNKJON26WPGZF7AAVOUZGD/ Code of Conduct: http://python.org/psf/codeofconduct/