I'm trying to run an external python file from a Jupyter notebook. The external python file takes a file path as an argument. I'd like to know how to pass this file path to the external .py file being run, from a string variable in the Jupyter notebook.
The following is what I've tried, and the error message which is returned:
path = '/Users/documents/'
%run script.py path
Which returns:
IndexError: list index out of range
However I get the expected results if I run:
%run script.py /Users/documents/
I'd like to be able to store the string as a variable for ease of use (not having to edit the file path in multiple parts of a notebook. Is there an easy solution?