Save workspace in IPython

前端 未结 5 1279
无人及你
无人及你 2020-12-13 14:42

Is it possible to save an IPython workspace (defined functions, different kinds of variables, etc) so that it can be loaded later?

This would be a similar function

5条回答
  •  醉话见心
    2020-12-13 15:15

    you can certainly do this in the ipython notebook.

    when the notebook is saved--either manually or by default config--the notebook is persisted as an .ipynb file, which is just a json file (an example in a github gist).

    Next time you start the ipython server in the directory where that file resides, the server will detect it.

    when you open that notebook in the browser, all of the code & config is there but unexecuted; you can execute the code in every cell by selecting execute all cells from the cells menu.

    in addition, you can manually persist snapshots of your notebook, as ipynb_checkpoints, which are stored in a directory of that name preceded by a dot.

    and finally, from the file menu option, you can persist your notebook as a pure python source file (.py)

提交回复
热议问题