Читать книгу Deep Learning for Physical Scientists - Edward O. Pyzer-Knapp - Страница 16
2.4.1 Why Use a Notebook?
ОглавлениеStandard Python scripts have their advantages – the code can be contained within a single file that can easily be run and debugged, without the need to step through and run multiple cells of code. Comments can be added to describe blocks of code, and docstrings can be used to provide more comprehensive descriptions of the script's functionality. So why use a notebook?
While Python scripts have a number of advantages while writing code, there are several shortfalls for their use in sharing your work. Comments and docstrings easily become overwhelming when detailed descriptions are required – turning a clean script into an awkward mess of comments and code blocks. This can make it difficult for others to read and understand what's going on. Furthermore, it does not allow you to incorporate plotting or other visualisations alongside your text. This is where notebooks come in.
Notebooks allow you to create a well‐structured document that incorporates executable code. The structuring allows you to create a comprehensive, flowing document – in the same way that you would for a paper or report. Unlike a traditional document, notebooks are enriched by their ability to incorporate executable code; code that can be used to run real experiments alongside the text and/or to produce interactive data visualisations. This is particularly important for sharing code and facilitating usability – providing a far more intuitive method of sharing code than a collection of Python scripts.