[Python-ideas] PEP 511: API for code transformers

Steven D'Aprano steve at pearwood.info
Thu Jan 28 20:01:58 EST 2016


On Thu, Jan 28, 2016 at 09:13:08PM +0000, Andrew Barnert via Python-ideas wrote:

> This kind of talk worries me. It's _already_ very easy to write AST 
> transformers. There's no need for any third-party code from PyPI, and 
> that "your own solution" that you have to write is a few lines of 
> trivial code.
> 
> I think a lot of people don't realize this.

I don't realise this.

Not that I don't believe you, but I'd like to see a tutorial that goes 
through this step by step and actually explains what this is all about. 
Or, if it really is just a matter of a few lines, even just a simple 
example might help.

For instance, the PEP includes a transformer that changes all string 
literals to "Ni! Ni! Ni!". Obviously it doesn't work as 
sys.set_code_transformers doesn't exist yet, but if I'm understanding 
you, we don't need that because it's already easy to apply that 
transformer. Can you show how? Something that works today?



-- 
Steve


More information about the Python-ideas mailing list