Checkout Hylang, a Lispish language that compiles to Python, or maybe a Lispish syntax for Python? You can write pieces of code in .hy files and import them from .py files and vice-versa.
And then you have macros like in macros that traverse and transform code.
And then you have macros like in macros that traverse and transform code.