1

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)

1 Answer 1

2

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 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.