title: Create namedtuple from Namspace?
body: <p>How do I initialize a <a href="https://docs.python.org/2/library/collections.html#collections.namedtuple" rel="nofollow noreferrer"><code>namedtuple</code></a> from a <a href="https://docs.python.org/2/library/argparse.html#argparse.Namespace" rel="nofollow noreferrer"><code>Namespace</code></a>?</p>
  
  <pre><code>import collections
  import argparse
  
  nt=collections.namedtuple("nt",["foo","bar"]) # _NOT_ "baz"!
  parser = argparse.ArgumentParser()
  parser.add_argument('--foo')
  parser.add_argument('--bar')
  parser.add_argument('--baz')
  args = parser.parse_args(...)
  </code></pre>
  
  <p><strong>What do I do if only <em>some</em> script arguments go into the namedtuple?</strong></p>
  
  <p>Here is what I came up with:</p>
  
  <pre><code>nt_param=nt(**{f:getattr(args,f,None) for f in nt._fields})
  </code></pre>
  
  <p>is there a more pythonic approach?</p>