I won't actively maintain it any longer, but will accept (sensible) Sure! If you still believe nbimporter fits your workflow best, the
#INSTALL IPYTHON NOTEBOOKS CODE#
However that alone does not prevent you from creating code debt. In brief, you'll write higher-quality code and re-use more of the code you've written, saving you a lot of time and trouble.Īnother approach is to use jupytext that allows you to save jupyter notebooks as plain python scripts from that you can import directly. utils.py that contains your functions, classes, constants, etc:īy consequently putting re-usable code into modules, you can use powerful IDEs to develop and debug code, create unit tests, combine multiple modules into shareable packages. It is as simple as creating a file in the same directory as your notebooks, e.g.
The proper way of doing it is to create a python module that contains your functions. While it is probably totally possible to fix these, doing it properly doesn't cause such problems in the first place. It is a hack, and doing it properly is very easy (see below).Moreover, you might want to edit re-usable code in a powerful IDE that will prevent you from making one or the other mistake. There's no straightforward way to do so within a notebook. It is advisable to create a unit test for almost any function. It is hard to test functions within notebooks.As soon as you start to fix something in the other notebook, you might break it and your analysis is not reproducible any more. As you use the functions in different projects, you'll want to fix bugs, make performance improvements or re-write it in a more elegant fashion.
#INSTALL IPYTHON NOTEBOOKS UPDATE#
Update 2019-06: I do not recommend any more to use nbimporter. Import IPython Notebooks as modules (with Jupyter v4).