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

Sven R. Kunze srkunze at mail.de
Fri Jan 29 13:18:15 EST 2016


On 29.01.2016 01:57, Victor Stinner wrote:
> A local transformation requires to register a global code transformer,
> but it doesn't mean that all files will be modified.

I think you should differentiate between "register" and "use".

"register" basically means "provide but don't use".
"use" basically means "apply the transformation".

(Same is already true for codecs.)

The PEP's "set_code_transformers" seem not to make that distinction.

> The code transformer can use various kinds of checks to decide if a file must
> be transformed and then which parts of the code should be transformed.
> Decorators was suggested as a good granularity.

As others pointed out, implicit transformations are not desirable. So, 
why would a transformer need to check if a file must be transformed? 
Either the author of a file explicitly wants the transformer or not. 
Same goes for the global option. Either it is there or it isn't.

Btw. I would really appreciate a reply to my prior post. ;)

Best,
Sven


More information about the Python-ideas mailing list