title: Python: Why do I get an "unexpected keyword argument" error?
body: <p>I am trying to set up a graph. For the initialization, I wanted the option of either starting with a collection of nodes and edges or not. So I gave them the default value None. Or so I thought:</p>
  <pre><code>def Graph():
      def __init__(self, nodes=None, edges=None, msg=&quot;test&quot;):
          &quot;&quot;&quot;
          assumes that the node and edge lists are the respective objects
          &quot;&quot;&quot;
          if nodes == None:
              self.nodes = []
          else:
              self.nodes = nodes
              
          if edges == None:
              self.edges = []
          else:
              self.edges = edges
          
          self.node_names = []
          for node in nodes:
              self.node_names.append(node.get_name())
              
          self.msg = msg
  
  </code></pre>
  <p>(the msg part was for testing the code with the simplest example possible)</p>
  <p>What I got was:</p>
  <pre><code>g = Graph(msg=&quot;33&quot;)
  Traceback (most recent call last):
  
    File &quot;&lt;ipython-input-29-cc459c9baef3&gt;&quot;, line 1, in &lt;module&gt;
      g = Graph(msg=&quot;33&quot;)
  
  TypeError: Graph() got an unexpected keyword argument 'msg'
  
  </code></pre>
  <p>Can anybody help me? It's probably a ridiculously simply thing, but I just don't see it, and I'm going slightly mad here...</p>