title: Named tuple and default values for optional keyword arguments
body: <p>I'm trying to convert a longish hollow "data" class into a named tuple. My class currently looks like this:</p>
  
  <pre><code>class Node(object):
      def __init__(self, val, left=None, right=None):
          self.val = val
          self.left = left
          self.right = right
  </code></pre>
  
  <p>After conversion to <code>namedtuple</code> it looks like:</p>
  
  <pre><code>from collections import namedtuple
  Node = namedtuple('Node', 'val left right')
  </code></pre>
  
  <p>But there is a problem here. My original class allowed me to pass in just a value and took care of the default by using default values for the named/keyword arguments. Something like:</p>
  
  <pre><code>class BinaryTree(object):
      def __init__(self, val):
          self.root = Node(val)
  </code></pre>
  
  <p>But this doesn't work in the case of my refactored named tuple since it expects me to pass all the fields. I can of course replace the occurrences of <code>Node(val)</code> to <code>Node(val, None, None)</code> but it isn't to my liking.</p>
  
  <p>So does there exist a good trick which can make my re-write successful without adding a lot of code complexity (metaprogramming) or should I just swallow the pill and go ahead with the "search and replace"? :)</p>