Reputation: 1341
Currently I am running a .py file at Jupyter Notebook using the following command:
!python /Users/manage.py /Users/u.data
Sometimes I have a really long file path. Thus, is there a way that I can execute it with anything similar to this?
path_name = "/Users/"
!python "{}manage.py".format(path_name) "{}u.data.format(path_name)
Upvotes: 1
Views: 829
Reputation: 6291
The notebook will interpolate variables in magic commands if you prefix the variable name with $
path_name = "/Users/"
py_file = "{}manage.py".format(path_name)
data = "{}u.data".format(path_name)
!python $py_file $data
Upvotes: 2