Rick
Rick

Reputation: 45251

run jupyter notebook using a dynamic name/string from another notebook

One can run a Jupyter notebook from another notebook using the %run magic:

%run my_notebook.ipynb

However, I have the path and name of the notebook I wish to run in a python variable, notebook_name.

Is it possible to run this notebook using the %run magic? If not, how else might I run the notebook using its name contained in a str variable?

Upvotes: 2

Views: 1537

Answers (1)

gmds
gmds

Reputation: 19885

You can use $ to evaluate Python variables for Jupyter magic functions in general, much like in a shell:

%run $notebook_name

Upvotes: 6

Related Questions