Skip to content

Commit 744c360

Browse files
committed
Arguments
1 parent f1827a6 commit 744c360

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ Arguments
556556

557557
### Inside Function Definition
558558
```python
559-
def f(<nondefault_args>): # def f(x, y)
560-
def f(<default_args>): # def f(x=0, y=0)
561-
def f(<nondefault_args>, <default_args>): # def f(x, y=0)
559+
def f(<nondefault_args>): ... # def f(x, y)
560+
def f(<default_args>): ... # def f(x=0, y=0)
561+
def f(<nondefault_args>, <default_args>): ... # def f(x, y=0)
562562
```
563563

564564

@@ -590,6 +590,13 @@ def add(*a):
590590
```
591591

592592
#### Legal argument combinations:
593+
```python
594+
def f(x, y, z): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)
595+
def f(*, x, y, z): # f(x=1, y=2, z=3)
596+
def f(x, *, y, z): # f(x=1, y=2, z=3) | f(1, y=2, z=3)
597+
def f(x, y, *, z): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3)
598+
```
599+
593600
```python
594601
def f(*args): # f(1, 2, 3)
595602
def f(x, *args): # f(1, 2, 3)
@@ -600,6 +607,7 @@ def f(x, *args, z): # f(1, 2, z=3)
600607
```python
601608
def f(**kwargs): # f(x=1, y=2, z=3)
602609
def f(x, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3)
610+
def f(*, x, **kwargs): # f(x=1, y=2, z=3)
603611
```
604612

605613
```python

index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,9 @@ <h3 id="insidefunctioncall">Inside Function Call</h3>
543543
&lt;function&gt;(&lt;positional_args&gt;, &lt;keyword_args&gt;) <span class="hljs-comment"># f(0, y=0)</span>
544544
</code></pre>
545545
<h3 id="insidefunctiondefinition">Inside Function Definition</h3>
546-
<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">(&lt;nondefault_args&gt;)</span>:</span> <span class="hljs-comment"># def f(x, y)</span>
547-
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(&lt;default_args&gt;)</span>:</span> <span class="hljs-comment"># def f(x=0, y=0)</span>
548-
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(&lt;nondefault_args&gt;, &lt;default_args&gt;)</span>:</span> <span class="hljs-comment"># def f(x, y=0)</span>
546+
<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">(&lt;nondefault_args&gt;)</span>:</span> ... <span class="hljs-comment"># def f(x, y)</span>
547+
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(&lt;default_args&gt;)</span>:</span> ... <span class="hljs-comment"># def f(x=0, y=0)</span>
548+
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(&lt;nondefault_args&gt;, &lt;default_args&gt;)</span>:</span> ... <span class="hljs-comment"># def f(x, y=0)</span>
549549
</code></pre>
550550
<h2 id="splatoperator"><a href="#splatoperator" name="splatoperator">#</a>Splat Operator</h2>
551551
<h3 id="insidefunctioncall-1">Inside Function Call</h3>
@@ -566,13 +566,19 @@ <h3 id="insidefunctiondefinition-1">Inside Function Definition</h3>
566566
<span class="hljs-number">6</span>
567567
</code></pre>
568568
<h4 id="legalargumentcombinations">Legal argument combinations:</h4>
569+
<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) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)</span>
570+
<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>
571+
<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>
572+
<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>
573+
</code></pre>
569574
<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>
570575
<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>
571576
<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>
572577
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, *args, z)</span>:</span> <span class="hljs-comment"># f(1, 2, z=3)</span>
573578
</code></pre>
574579
<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>
575580
<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>
581+
<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>
576582
</code></pre>
577583
<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>
578584
<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>

0 commit comments

Comments
 (0)