Skip to content

Commit 199cbce

Browse files
committed
content/scripts: Update for clarity
1 parent 7d61f6d commit 199cbce

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

content/scripts.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,33 @@ In this episode, we will learn how to automate your work using Python scripts so
3838
From Jupyter notebooks to Python scripts
3939
-----------------------------------------
4040

41+
.. highlight:: console
42+
43+
4144
Save as Python script
4245
---------------------
4346

4447
Jupyter notebooks can be parameterized for instance using `papermill <https://papermill.readthedocs.io/en/latest/>`_. It can be an attractive approach when you have short notebooks (to generate automatically plots/reports) but as soon as you have more complex tasks to execute, we strongly recommend to generate Python scripts. This will also force you to modularize your code. See `CodeRefinery's lesson on Modular code development <https://coderefinery.github.io/modular-type-along/>`__.
4548

46-
Within JupyterLab, you can export any Jupyter notebook to a Python script:
49+
You need to convert the notebook to a Python file.
50+
Check the `JupyterLab documentation <https://jupyterlab.readthedocs.io/en/stable/user/export.html>`_ for more information.
51+
You can get a command line by (File → New Launcher → Terminal - if you
52+
go through New Launcher, your command line will be in the directory
53+
you are currently browsing), you can convert files in the terminal by running::
4754

48-
.. figure:: https://jupyterlab.readthedocs.io/en/stable/_images/exporting-menu.png
55+
$ jupyter nbconvert --to script your_notebook_name.ipynb
4956

50-
Select File (top menu bar) → Export Notebook as → **Export notebook to Executable Script**.
5157

5258

53-
.. highlight:: console
59+
Within JupyterLab, you can export any Jupyter notebook to a Python
60+
script, but this downloads it to your own computer and then you need
61+
to copy it to a place you are working:
5462

55-
Actually, you could also export your notebook in many other formats.
56-
Check the `JupyterLab documentation <https://jupyterlab.readthedocs.io/en/stable/user/export.html>`_ for more information.
57-
If you are working by the command line (File → New → Terminal), you can also convert files in the terminal by running::
63+
.. figure:: https://jupyterlab.readthedocs.io/en/stable/_images/exporting-menu.png
64+
:scale: 50%
65+
66+
Select File (top menu bar) → Export Notebook as → **Export notebook to Executable Script**.
5867

59-
$ jupyter nbconvert --to script your_notebook_name.ipynb
6068

6169

6270
Exercises 1

0 commit comments

Comments
 (0)