How to define function arguments partially? Python
<p>If I have a function with some arguments, I can define a duck function like this:</p>

<pre><code>&gt;&gt;&gt; def f(x, y=0, z=42): return x + y * z 
... 
&gt;&gt;&gt; f(1,2,3)
7
&gt;&gt;&gt; g = f
&gt;&gt;&gt; f(1,2)
85
&gt;&gt;&gt; g(1,2)
85
</code></pre>

<p>I've tried to override the arguments partially but this didn't work:</p>

<pre><code>&gt;&gt;&gt; g = f(z=23)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: f() takes at least 1 argument (1 given)
</code></pre>

<p><strong>How do I define function arguments partially for the duck function?</strong> </p>

<p>Use <a href="http://yourFile.write(str(self.textEdit.toPlainText()))" rel="nofollow"><code>functools.partial</code></a></p>

<pre><code>&gt;&gt;&gt; from functools import partial
&gt;&gt;&gt; def f(x, y=0, z=42): return x + y * z
... 
&gt;&gt;&gt; g = partial(f, z=23)
&gt;&gt;&gt; g(1,2)
47
&gt;&gt;&gt; f(1,2,23)
47
</code></pre>

python function arguments keyword-argument