回答編集履歴

2

些細

2021/09/08 15:33

投稿

quickquip
quickquip

スコア11051

test CHANGED
@@ -90,20 +90,18 @@
90
90
 
91
91
 
92
92
 
93
+ def do_twice(f):
94
+
95
+ """関数オブジェクトを受け取って2回、別の引数で呼び出す"""
96
+
97
+ f('1回目')
98
+
99
+ f('2回目')
100
+
101
+
102
+
93
103
  f2 = create_func('例えばこれ')
94
104
 
95
-
96
-
97
- def do_twice(f):
98
-
99
- """関数オブジェクトを受け取って2回、別の引数で呼び出す"""
100
-
101
- f('1回目')
102
-
103
- f('2回目')
104
-
105
-
106
-
107
105
  do_twice(f2)
108
106
 
109
107
  ```
@@ -288,4 +286,4 @@
288
286
 
289
287
  が**だいたい等価**なのです。
290
288
 
291
- routeを引数付きで呼び出す方が先に行れるのです。
289
+ routeを引数付きで呼び出す方が先にれるのです。

1

追記

2021/09/08 15:33

投稿

quickquip
quickquip

スコア11051

test CHANGED
@@ -223,3 +223,69 @@
223
223
 
224
224
 
225
225
  このどこかに、?? となっている箇所があるのだと思いますが、それがどのあたりなのかは分かりません。
226
+
227
+
228
+
229
+ ----
230
+
231
+ (追記)
232
+
233
+
234
+
235
+ [https://docs.python.org/ja/3/reference/compound_stmts.html#index-20](https://docs.python.org/ja/3/reference/compound_stmts.html#index-20)
236
+
237
+
238
+
239
+ > @f1(arg)
240
+
241
+ > @f2
242
+
243
+ > def func(): pass
244
+
245
+ >
246
+
247
+ > は、だいたい次と等価です
248
+
249
+ >
250
+
251
+ > def func(): pass
252
+
253
+ > func = f1(arg)(f2(func))
254
+
255
+
256
+
257
+ とあります。つまり、
258
+
259
+
260
+
261
+ ```
262
+
263
+ @route('/index')
264
+
265
+ def index():
266
+
267
+ print(f'indexを呼び出したよ')
268
+
269
+ ```
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+ ```
278
+
279
+ def index():
280
+
281
+ print(f'indexを呼び出したよ')
282
+
283
+ index = route('/index')(index)
284
+
285
+ ```
286
+
287
+
288
+
289
+ が**だいたい等価**なのです。
290
+
291
+ routeを引数付きで呼び出す方が先に行われるのです。