How to pass command line arguments to IPython jupyter notebook
I am new to Ipython. I currently have Ipython installed using Anaconda and have written some code to build a diagram using the jupyter notebook UI. I want to pass multiple arguments to my working script using the argparse module. below is the code.
import argparse
parser = argparse.ArgumentParser(description = 'Process display arguments')
parser.add_argument('-t', "--test_name", help="Mandatory test name directory path", type=str)
parser.add_argument('-s', "--symbolSet", nargs = '?', help="Optional symbolset", const = 'baz', default = 'deafultOne')
args = parser.parse_args()
if args.test_name is None:
print("test_name argument is mandatory.. Use option -h for help.. Exiting..")
sys.exit(1)
Now, how can I pass these arguments when executing my script through the UI or can I run the command line script and still be able to draw the diagram? I am working on a windows machine. Please let me know if you need more information. On this.
+4
source to share
1 answer
You can use the argparse argument with class syntax like this in jupyter.
class Args:
test_name = ''
symbolSet = 'defaultOne'
args=Args()
and there is an automatic conversion script.
http://35.192.144.192:8000/arg2cls.html
0
source to share