title: Passing specific arguments to Boost Python function with default arguments
body: <p>I'm trying to create a nice interface for making HTTP calls in my game engine via Python, I have run into a bit of a problem, however.</p>
  
  <p>I have a single function, <code>get_async</code> which launches a <a href="/questions/tagged/curl" class="post-tag" title="show questions tagged &#39;curl&#39;" rel="tag">curl</a> request for the specified URL. The function is defined inside an <code>http_manager</code> class, like so:</p>
  
  <pre><code>struct http_manager
  {
      typedef function&lt;void(boost::shared_ptr&lt;http_response&gt;)&gt; response_callback_type;
      typedef function&lt;void(size_t)&gt; write_callback_type;
  
      void get_async(
          const string&amp; url,
          const http_headers_type&amp; headers = http_headers_type(),
          const http_data_type&amp; data = http_data_type(),
          response_callback_type on_response = nullptr,
          write_callback_type on_write = nullptr
          );
  };
  </code></pre>
  
  <p>I am able to successfully make this call in Python:</p>
  
  <pre><code>http.get_async('http://www.google.ca')
  </code></pre>
  
  <p>However, I want to make a call like this:</p>
  
  <pre><code>http.get_async('http://www.google.ca', on_response=f)
  </code></pre>
  
  <p>The key here is that I want to explicitly specify the arguments by name and let all the others be the defaults, just like in regular Python.</p>
  
  <p>Unfortunately, when I do this, I get the following error back from Python:</p>
  
  <pre><code>ArgumentError: Python argument types in
      HttpManager.get_async(HttpManager, str)
  did not match C++ signature:
      get_async(struct naga::http_manager {lvalue}, class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; url)
      get_async(struct naga::http_manager {lvalue}, class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; url, class std::vector&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &gt; headers)
      get_async(struct naga::http_manager {lvalue}, class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; url, class std::vector&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &gt; headers, class std::map&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &gt; data)
      get_async(struct naga::http_manager {lvalue}, class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; url, class std::vector&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &gt; headers, class std::map&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &gt; data, class std::function&lt;void __cdecl(class boost::shared_ptr&lt;struct naga::http_response&gt;)&gt; on_response)
      get_async(struct naga::http_manager {lvalue}, class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; url, class std::vector&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &gt; headers, class std::map&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &gt; data, class std::function&lt;void __cdecl(class boost::shared_ptr&lt;struct naga::http_response&gt;)&gt; on_response, class std::function&lt;void __cdecl(unsigned int)&gt; on_write)
  </code></pre>
  
  <p>I'm confused as to why it thinks that the argument signature is <code>HttpManager.get_async(HttpManager, str)</code> when I'm clearly passing 3 arguments (<code>self</code>, <code>url</code> and <code>on_response</code>).</p>
  
  <p>Here are the relevant bits from my <code>BOOST_PYTHON_MODULE</code> block:</p>
  
  <pre><code>BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(http_manager_get_async_overloads, http_manager::get_async, 1, 5)
  
  class_&lt;http_manager, noncopyable&gt;("HttpManager", no_init)
      .def("get_async", &amp;http_manager::get_async, http_manager_get_async_overloads(args("url", "headers", "data", "on_response", "on_write")))
      ;
  </code></pre>
  
  <p>Thank you for reading and any help is greatly appreciated!</p>