4 ms·
Python being python, can't you swap out the import machinery and change which compile function is called, alternatively call your own preprocessor before compil
by kzrdude 7y ago
Python being python, can't you swap out the import machinery and change which compile function is called, alternatively call your own preprocessor before compiling?
- rcxdude 7y agoYup. You can basically write your own language with different syntax and get python to treat it like any other python code. Hy is a language which works this way: https://github.com/hylang/hy https://github.com/hylang/hy (see this part of their documentation for how the user can use this: https://docs.hylang.org/en/master/language/interop.html#using-hy-from-python https://docs.hylang.org/en/master/language/interop.html#usin...) I think goto has been implemented in a few different ways in python. Here's another example which abuses existing syntax and edits the bytecode of the function after its compiled: https://pypi.org/project/goto-statement/ https://pypi.org/project/goto-statement/
- sitkack 7y agohttps://github.com/lihaoyi/macropy https://github.com/lihaoyi/macropy