回答編集履歴

1

追記

2018/10/08 08:56

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -1,6 +1,64 @@
1
1
  事前に確認しておきますが、
2
2
 
3
3
  『デフォルト値の有無』と『キーワード引数の強制』は関係ないです。
4
+
5
+ ```Python
6
+
7
+ >>> def func(a=0): pass
8
+
9
+ ...
10
+
11
+ >>> func(1)
12
+
13
+ >>> func(a=1)
14
+
15
+ >>>
16
+
17
+ ```
18
+
19
+
20
+
21
+ ```Python
22
+
23
+ >>> def func(*, a): pass
24
+
25
+ ...
26
+
27
+ >>> func(1)
28
+
29
+ Traceback (most recent call last):
30
+
31
+ File "<stdin>", line 1, in <module>
32
+
33
+ TypeError: func() takes 0 positional arguments but 1 was given
34
+
35
+ >>> func(a=1)
36
+
37
+ >>>
38
+
39
+ ```
40
+
41
+
42
+
43
+ ```Python
44
+
45
+ >>> def func(*, a=0): pass
46
+
47
+ ...
48
+
49
+ >>> func(1)
50
+
51
+ Traceback (most recent call last):
52
+
53
+ File "<stdin>", line 1, in <module>
54
+
55
+ TypeError: func() takes 0 positional arguments but 1 was given
56
+
57
+ >>> func(a=1)
58
+
59
+ >>>
60
+
61
+ ```
4
62
 
5
63
 
6
64