3 ms·
True, but I think that source transformation on import are already supported in Python ("officially") based on importlib [0-1]. Here's an example use cases whe
by leethargo 4y ago
True, but I think that source transformation on import are already supported in Python ("officially") based on importlib [0-1].
Here's an example use cases where the author is trying to create a Python enum from Thrift specs: [2]. The issue here is that the spec code is not necessarily valid Python, but can be fixed easily with some search & replace operations.
[0] https://docs.python.org/3/reference/import.html https://docs.python.org/3/reference/import.html
[1] https://docs.python.org/3/library/modules.html https://docs.python.org/3/library/modules.html
[2] http://wakandan.github.io/2018/06/07/python3-import-hook.html http://wakandan.github.io/2018/06/07/python3-import-hook.htm...
- leethargo 4y agoOne of the benefits of implementing your own module finder and loader is that you could use a separate file extension to avoid confusion with actual Python code.