if __name__ == '__main__' in IPython

前端 未结 4 694
情话喂你
情话喂你 2021-01-01 13:30

I have Python scripts that use the if __name__ == \'__main__\' trick to have some code only run when the script is called as a script and not when it is loaded

4条回答
  •  鱼传尺愫
    2021-01-01 13:44

    IPython automatically executes the code you write with the %edit command. You can use %edit -x to specify that you do NOT want to run the code you were just editing.

    http://ipython.org/ipython-doc/stable/api/generated/IPython.core.magics.code.html

提交回复
热议问题