Using sys.argv in examples

Note that your example will be run by sphinx-gallery without arguments.

Out:

sys.argv: ['/home/docs/checkouts/readthedocs.org/user_builds/sphinx-gallery/checkouts/latest/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.021 seconds)

Gallery generated by Sphinx-Gallery