(Apologies if this appears twice: I attempted to create a new thread using
the Web interface but do not see any sign of it having been created.)

When people suggest changes to Python's syntax on this list, it is often
suggested that they might want to try doing so using an import hook.

In fact, this was suggested as recently as two days ago when Andrew Barnert
wrote [1]

> Unfortunately, the boilerplate to write an import hook is more
complicated than you’d
like (and pretty hard to figure out the first time), and the support for
filtering on the
token stream (the most obvious way to do this one) rather than the text
stream, AST, or
bytecode is pretty minimal and clumsy.

In an attempt to make it easier to create import hooks to "play" with
non-standard syntax, I have created a library that is simply called "ideas"
[2].
It includes quite a few toy examples meant to illustrate what can be done.
It also includes a slightly less minimal and hopefully less clumsy way of
filtering the token stream. A reasonably complete documentation is
available [3].

I was planning to work some more on it but the recent comment by Andrew
Barnert gave me the impetus to finish a first draft and mention it
publicly. While it "works for me", consider it to be a pre-alpha release,
which is ready for your suggestions, criticisms, and other comments.

My hope is that eventually enough examples will be included so that,
instead of simply suggesting "why don't you write an import hook for
testing your proposed syntax", one could say "you can use transformations
similar to that of examples X and Y of ideas to create an import hook for
testing your proposed syntax".

André Roberge

[1]
https://mail.python.org/archives/list/python-ideas@python.org/message/UNL62EMSNPA5USUS7SCEQZQ63PVP2FDL/
[2] Code on github: https://github.com/aroberge/ideas; see the
documentation for the choice of name.
[3] Documentation: https://aroberge.github.io/ideas/docs/html/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/VWPD2CGZFYA5YJT7IJDCIGAGIGILAWCY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to