argparse module How to add option without any argument?
<p>Once again, I need your help to fix things:
I have create a script using argparse.
It has to take as options a configuration file name, and user can specify whether they need to proceed totally the script or only simulate it.</p>

<p>The args to be passed:
./script -f config_file -s or ./script -f config_file.</p>

<p>It's ok for the -f config_file part, but It keeps asking me for arguments for the -s which is optionnal and should not be followed by any.</p>

<p>I have tried this:</p>

<pre><code>    parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file')
#parser.add_argument('-s', '--simulate', nargs = '0')
args = parser.parse_args()
if args.file:
    config_file = args.file
if args.set_in_prod:
        simulate = True
else:
    pass
</code></pre>

<p>With the following errors:</p>

<pre><code>File "/usr/local/lib/python2.6/dist-packages/argparse.py", line 2169, in _get_nargs_pattern
nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
</code></pre>

<p>TypeError: can't multiply sequence by non-int of type 'str'</p>

<p>And same errror with '' instead of '0' for </p>
