Skip to content

Instantly share code, notes, and snippets.

@parente
Last active August 23, 2018 13:16
Show Gist options
  • Save parente/8932dac5a430dba4c17f49af16568da7 to your computer and use it in GitHub Desktop.
Save parente/8932dac5a430dba4c17f49af16568da7 to your computer and use it in GitHub Desktop.
Jupyter Tidbit: %run your ipynb file

Summary

The %run magic provided by IPython not only supports the execution of regular Python scripts, it also runs Jupyter Notebook files (.ipynb).

Example

Binder

The run_demo.ipynb notebook below uses %run to execute all of the cells in reusable_stuff.ipynb. Once it does, both globals defined in reusable_stuff are available in run_demo for use.

Why is this useful?

You can maintain a handy notebook of useful recipes that you can than %run to reuse in other notebooks. Just remember that this setup can decrease the reproducibility of your work unless you provide your recipe notebook alongside any notebook that uses it when you share.

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment