How to use IPython magic within a script to auto reload modules?

前端 未结 1 1303
渐次进展
渐次进展 2020-12-17 06:54

I am trying to include some of the IPython built-in magic functions to auto reload modules when I am running a script. So I have tried this:

if __IPYTHON__:
         


        
相关标签:
1条回答
  • 2020-12-17 07:20

    Thank you for the link Gall!!! Whit your help I came up with the following solution:

    from IPython import get_ipython
    ipython = get_ipython()
    
    if '__IPYTHON__' in globals():
        ipython.magic('load_ext autoreload')
        ipython.magic('autoreload 2')
    
    0 讨论(0)
提交回复
热议问题