You may want to look into the %load
command which works in a notebook too, see here and here.
Plus, in a cell you can do import <name of script>
to import it into the notebook namespace. (Note you don’t need the .py
).
As a different route, you may also be interested in Jupytext, see related answer here.
(Note: I had typos in my second item listed in my first answer. They’ve been fixed now).