[issue43037] Importlib reload by module name (String)

Brett Cannon report at bugs.python.org
Wed Jan 27 14:04:41 EST 2021


Brett Cannon <brett at python.org> added the comment:

Thanks for the idea, Stefan, but I'm going to close this as something we don't want to do. `importlib.reload()` purposefully takes a module object as that's what is going to get mutated/changed and it must already exist. The other importlib functions take a string because the module might not even exist yet.

And as Serhiy said, reloading is a bit dangerous and shouldn't be taken lightly. It primarily exists to reload a module when you're working in the REPL and editing a file live, not for anything fancy during execution of production code. So keeping it squarely targeted the REPL case and making it a bit harder for other cases is a good thing in my opinion.

----------
resolution:  -> rejected
stage:  -> resolved
status: open -> closed
versions: +Python 3.10 -Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43037>
_______________________________________


More information about the Python-bugs-list mailing list