title: Python Option Parser: Boolean flag with optional parameters
body: <p>I'm using optparse.OptionParser to manage arguments for some scripts, and something I was wondering / would like to do is have boolean flags (i.e <code>action=store_true</code>) that can also accept a parameter.</p>
  
  <p>To put this into context, I've got a application that can use as many GPU/Processors as it finds on the machine. For a variety of reasons sometimes you want to limit the number of devices it uses, and instead of further cluttering the command line, I'd like to be able to:</p>
  
  <pre><code>script -c -g
  </code></pre>
  
  <p>meaning use all you can of all cpus and gpus, and </p>
  
  <pre><code>script -c 2 -g 3
  </code></pre>
  
  <p>meaning limit the script execution to 2 CPUs and 3 GPUs. </p>
  
  <p>After reading the optparse documentation, I'm none the wiser. Oh great SO gurus! Lend me your wisdom!</p>