|
|
@ -54,7 +54,7 @@ |
|
|
|
|
|
|
|
<body> |
|
|
|
<header> |
|
|
|
<aside>September 5, 2022</aside> |
|
|
|
<aside>September 12, 2022</aside> |
|
|
|
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
|
|
|
</header> |
|
|
|
|
|
|
@ -621,23 +621,22 @@ func(*args, **kwargs) |
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>add(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>) |
|
|
|
<span class="hljs-number">6</span> |
|
|
|
</code></pre> |
|
|
|
<div><h4 id="legalargumentcombinations">Legal argument combinations:</h4><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*, x, y, z)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, *, y, z)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, y, *, z)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3)</span> |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*args)</span>:</span> ... <span class="hljs-comment"># f(1, 2, 3)</span> |
|
|
|
<div><h4 id="legalargumentcombinations">Legal argument combinations:</h4><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*args)</span>:</span> ... <span class="hljs-comment"># f(1, 2, 3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, *args)</span>:</span> ... <span class="hljs-comment"># f(1, 2, 3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*args, z)</span>:</span> ... <span class="hljs-comment"># f(1, 2, z=3)</span> |
|
|
|
</code></pre> |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(**kwargs)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, **kwargs)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*, x, **kwargs)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3)</span> |
|
|
|
</code></pre> |
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*args, **kwargs)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, *args, **kwargs)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*args, y, **kwargs)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3)</span> |
|
|
|
</code></pre> |
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*, x, y, z)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, *, y, z)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3)</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, y, *, z)</span>:</span> ... <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3)</span> |
|
|
|
</code></pre> |
|
|
|
<div><h3 id="otheruses">Other Uses</h3><pre><code class="python language-python hljs"><list> = [*<coll.> [, ...]] <span class="hljs-comment"># Or: list(<collection>) [+ ...]</span> |
|
|
|
<tuple> = (*<coll.>, [...]) <span class="hljs-comment"># Or: tuple(<collection>) [+ ...]</span> |
|
|
|
<set> = {*<coll.> [, ...]} <span class="hljs-comment"># Or: set(<collection>) [| ...]</span> |
|
|
@ -2906,7 +2905,7 @@ $ pyinstaller script.py --add-data '<path>:.' <span class="hljs-comment"> |
|
|
|
|
|
|
|
|
|
|
|
<footer> |
|
|
|
<aside>September 5, 2022</aside> |
|
|
|
<aside>September 12, 2022</aside> |
|
|
|
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
|
|
|
</footer> |
|
|
|
|
|
|
|