title: Python argparse how to pass False from the command line?
body: <p>I am trying to sort out how to pass the boolean value False from the command line to the argparser. My origninal code looked like:</p>
  
  <pre><code>import argparse
  parser = argparse.ArgumentParser(allow_abbrev=True)
  parser.add_argument('-data', default=True, type=bool, help='uses the history file')
  args = parser.parse_args(sys.argv[1:])
  </code></pre>
  
  <p>From the command line, I typed: python myscript.py -data False</p>
  
  <p>Also variations with single &amp; double quotes around False. When I examine the contents of the args namespace, args.data is always True.</p>
  
  <p>So I changed the argument definition from bool to str, with a string "True" default as shown below:</p>
  
  <pre><code>parser.add_argument('-data', default="True", type=str, help='uses the history file')
  </code></pre>
  
  <p>I then added some massaging of the args to get the boolean value I really wanted:</p>
  
  <pre><code>if re.search("f", args.data, re.I):
     args.data = False
  else:
     args.data = True
  </code></pre>
  
  <p>This workaround does work. Is there a better way to do this?</p>