Get the latest tech news
Python’s Preprocessor
Every now and then you hear outrageous claims such as “Python has no preprocessor”.
If your language extension transforms syntactically valid Python, it is possible to use the ast module to parse the source file, modify the resulting abstract syntax tree and finally unparse it. Custom codecs in conjunction with path configuration files can drastically change the behavior of the Python interpreter. If you want to play around with your own preprocessors but do not wish to mess with site-packages directly, introduce path configuration files and write all the boilerplate yourself, you can instead use magic_codec.
Or read this on Hacker News