.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_auto_examples_plot_sys_argv.py>` to download the full example code or run this example in your browser via Binder
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_sys_argv.py:


Using ``sys.argv`` in examples
==============================

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





.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none

    ('sys.argv:', [u'/build/sphinx-gallery-0.2.0/examples/plot_sys_argv.py'])
    ('parsed args:', Namespace(option='default'))




|


.. code-block:: python


    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)


.. _sphx_glr_download_auto_examples_plot_sys_argv.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example


  .. container:: binder-badge

    .. image:: https://static.mybinder.org/badge.svg
      :target: https://mybinder.org/v2/gh/sphinx-gallery/sphinx-gallery.github.io/master?urlpath=lab/tree/notebooks/auto_examples/plot_sys_argv.ipynb
      :width: 150 px


  .. container:: sphx-glr-download

     :download:`Download Python source code: plot_sys_argv.py <plot_sys_argv.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: plot_sys_argv.ipynb <plot_sys_argv.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
