Re:Show HN: Wat – Deep inspection of Python objects
by Rhapso on Thursday July 25, 2024 @07:10PM
(#41074406)
Python has code execution at import time. Just grab the global context, and overwrite the module with a callable.
[ Parent
| on HN ]
Re:Show HN: Wat – Deep inspection of Python objects
by skitter on Thursday July 25, 2024 @08:07PM
(#41074753)
Afaik 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!