How to clear variables in ipython?

前端 未结 7 2293
逝去的感伤
逝去的感伤 2020-12-02 04:56

Sometimes I rerun a script within the same ipython session and I get bad surprises when variables haven\'t been cleared. How do I clear all variables? And is it possible to

相关标签:
7条回答
  • 2020-12-02 05:35

    Adding the following lines to a new script will clear all variables each time you rerun the script:

    from IPython import get_ipython
    get_ipython().magic('reset -sf') 
    

    To make life easy, you can add them to your default template.

    In Spyder: Tools>Preferences>Editor>Edit template

    0 讨论(0)
提交回复
热议问题