Assembling Python module on fly, dynamic import
问题 I'm trying to get myself familiar with importlib hooks. I want to implement an ability to directly import non-pythonic files written in other language, and maintain source maps, so raising SyntaxError s with line numbers will still give meaningful stacktraces. My approach to loading foreign files is assembling Pythonic source, then compiling it and executing it in the desired context. I've read in the documentation that implementing importlib.abc.SourceLoader seems to be my choice — however,