0

I am trying to find a way to run a command line script in Jupyter notebook using a variable as one of the input arguments.

For now I am able to do the following:

%run '/global/scripts/plot_modes.py' '0001' .5 0.5

But, I want to be able to do the following in order to throw this into a loop.

suffix = '0001'
%run '/global/scripts/plot_modes.py' suffix .5 0.5

I've tried converting the suffix variable to an integer and all other types of things but an error only appears when the variable takes the place of the '0001' input.

I've searched online but only seem to find how to get argument outputs as variables and not how to load in a variable as the input argument. The other alternative would be to convert the script into a function but this is turning out to be very messy. Any tips or leads are welcome!

2
  • 1
    Does %run '/global/scripts/plot_modes.py' $suffix .5 0.5 work? Commented Aug 11, 2022 at 3:05
  • Several options here - stackoverflow.com/questions/59343479/…. Please see if it helps. Commented Aug 11, 2022 at 5:12

0

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.