[issue38399] Error message persists when reimporting library

Steven D'Aprano report at bugs.python.org
Mon Oct 7 18:49:49 EDT 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

Importing the second and subsequent times reloads the module from the system cache. Instead, you can:

- run ``del sys.modules['hexdump']`` and then ``import hexdump``;

- call ``importlib.reload(hexdump)``; or

- restart the REPL.

Remember that reloading the module won't redefine any existing classes or instances you created from the old module, they will continue to reference the old module code until they are destroyed and recreated. So the last option (restarting the REPL) is usually the most effective. But with care, reload(hexdump) should do the trick.

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list