All Projects → nvbn → __transformers__

nvbn / __transformers__

Experimental module for AST transformations

Programming Languages

python
139335 projects - #7 most used programming language

Experimental module for AST transformations

Install

pip install git+https://github.com/nvbn/__transformers__

Usage

Available transformations:

  • ellipsis_partialmap(lambda x: x + 1, ...) to lambda y: map(lambda x: x + 1, y);
  • matmul_pipe"hello world" @ print to print("hello world").

Enable transformations in code:

from __transformers__ import ellipsis_partial, matmul_pipe
  
range(10) @ map(lambda x: x ** 2, ...) @ list @ print 

Run code with transformations:

➜ python -m __transformers__ -m python_module   
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

➜ python -m __transformers__ python/module/path.py                 
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

Manually enable transformations from code:

from __transformers__ import setup

setup()

import module_that_use_transformers

Rationale

License MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].