Reimport a module in python while interactive

前端 未结 6 1302
后悔当初
后悔当初 2020-11-27 08:45

I know it can be done, but I never remember how.

How can you reimport a module in python? The scenario is as follows: I import a module interactively and tinker wit

6条回答
  •  悲&欢浪女
    2020-11-27 09:38

    Actually, in Python 3 the module imp is marked as DEPRECATED. Well, at least that's true for 3.4.

    Instead the reload function from the importlib module should be used:

    https://docs.python.org/3/library/importlib.html#importlib.reload

    But be aware that this library had some API-changes with the last two minor versions.

提交回复
热议问题