3 ms·
Python has code execution at import time. Just grab the global context, and overwrite the module with a callable.
by Rhapso 2y ago
Python has code execution at import time. Just grab the global context, and overwrite the module with a callable.
- skitter 2y agoAfaik the import sets the module in the importing module's context only after the code in the imported module is run. Edit: Oh, you don't mean in the importing module's globals, you mean `sys.modules`. Yeah that works!
- Rhapso 2y agoactually, no you were right about what I meant but i'll claim credit for helping you realize there was a better way XD