title: Creating a partial function, but preserving the kind of parameters in the resulting function
body: <p>It's possible to create a partial function in python with the <code>partial</code> function from <code>functools</code>, however doing so will usually change some parameters to be keyword-only parameters. For example:</p>
  <pre class="lang-py prettyprint-override"><code>def foo(a, b, c, d):
      return a*b - c*d
  
  bar = functools.partial(foo, b=2, c=3)
  
  inspect.signature(foo)
  # &lt;Signature (a, b, c, d)&gt;
  
  inspect.signature(bar)
  # &lt;Signature (a, *, b=2, c=3, d)&gt;
  </code></pre>
  <p>In the example, parameter <code>a</code> keeps its original <a href="https://docs.python.org/3/library/inspect.html#inspect.Parameter.kind" rel="nofollow noreferrer">kind</a>, but <code>d</code> is keyword-only now. Is there a way to bind a function's parameters to some values while preserving the other parameters' kind? In other words, a way to make <code>bar</code> from above functionally equivalent to:</p>
  <pre class="lang-py prettyprint-override"><code>def bar(a, d):
      return a*2 - 3*d
  </code></pre>
  <p>but <code>bar</code> could be any function, and any combination of parameters could be bound.</p>