python argparse: default flag
<p>My script needs to take exactly two arguments. The third one below is what I am struggling with.</p>

<p><code>python myscript -e arg1 arg2</code></p>

<p><code>python myscript -i arg1 arg2</code></p>

<p><code>python myscript arg1 arg2</code></p>

<p>I could easily get the first two to work using <code>argparse</code> but I couldn't figure out how to get the third one to work with argparse. Basically, when no flag is specified, I would like to do same processing as with <code>-e</code> flag specified. The script should error out if exactly 2 arguments haven't been specified.</p>

<p>I checked python documentation and saw that there is a way to specify a default value to a flag but I couldn't find a way to make the argument itself; a default one. </p>

<p><code>parser.add_argument('',nargs=2)</code></p>

<p>Although a newbie to python, I knew it was dumb to try the above thing, but somehow hoped that magically it would work. :)</p>

<p>Could someone help me find a way to get the no-argument case to work?
Thanks</p>