Proper way to reload a python module from the console

前端 未结 8 1914
迷失自我
迷失自我 2020-12-03 04:51

I\'m debugging from the python console and would like to reload a module every time I make a change so I don\'t have to exit the console and re-enter it. I\'m doing:

<
相关标签:
8条回答
  • 2020-12-03 05:16

    You could also try twisted.python.rebuild.rebuild.

    0 讨论(0)
  • 2020-12-03 05:21

    For python3, reload has been moved to imp module. you can use imp.reload(). You can refer to this post.

    >>> import imp
    >>> import project # get module reference for reload
    >>> imp.reload(project.models.user) # reload step 1
    >>> from project.models.user import * # reload step 2
    
    0 讨论(0)
提交回复
热议问题