Note
Click here to download the full example code or run this example in your browser via Binder
Using sys.argv
in examples¶
Note that your example will be run by sphinx-gallery without arguments.
Out:
sys.argv: ['/build/sphinx-gallery-80ri34/sphinx-gallery-0.2.0/examples/plot_sys_argv.py']
parsed args: Namespace(option='default')
import argparse
import sys
parser = argparse.ArgumentParser(description='Toy parser')
parser.add_argument('--option', default='default',
help='a dummy optional argument')
print('sys.argv:', sys.argv)
print('parsed args:', parser.parse_args())
Total running time of the script: ( 0 minutes 0.001 seconds)