title: argparse action or type for comma-separated list
body: <p>I want to create a command line flag that can be used as</p>
  
  <pre><code>./prog.py --myarg=abcd,e,fg
  </code></pre>
  
  <p>and inside the parser have this be turned into <code>['abcd', 'e', 'fg']</code> (a tuple would be fine too).</p>
  
  <p>I have done this successfully using <code>action</code> and <code>type</code>, but I feel like one is likely an abuse of the system or missing corner cases, while the other is right. However, I don't know which is which.</p>
  
  <p>With <code>action</code>:</p>
  
  <pre><code>import argparse
  
  class SplitArgs(argparse.Action):
      def __call__(self, parser, namespace, values, option_string=None):
          setattr(namespace, self.dest, values.split(','))
  
  
  parser = argparse.ArgumentParser()
  parser.add_argument('--myarg', action=SplitArgs)
  args = parser.parse_args()
  print(args.myarg)
  </code></pre>
  
  <p>Instead with <code>type</code>:</p>
  
  <pre><code>import argparse
  
  def list_str(values):
      return values.split(',')
  
  parser = argparse.ArgumentParser()
  parser.add_argument('--myarg', type=list_str)
  args = parser.parse_args()
  print(args.myarg)
  </code></pre>