回答編集履歴

1

コード微修正(冗長な部分の排除)

2020/07/12 21:29

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -208,7 +208,7 @@
208
208
 
209
209
  node.decorator_list = [
210
210
 
211
- x for x in node.decorator_list[:] if x.id != "recompile_with_timeit"
211
+ x for x in node.decorator_list if x.id != "recompile_with_timeit"
212
212
 
213
213
  ]
214
214
 
@@ -226,7 +226,7 @@
226
226
 
227
227
  target=ast.Name(id="_", ctx=ast.Store()),
228
228
 
229
- iter=node.items[0].context_expr,
229
+ iter=expr,
230
230
 
231
231
  body=node.body,
232
232
 
@@ -242,13 +242,13 @@
242
242
 
243
243
  src = inspect.getsource(func)
244
244
 
245
+
246
+
245
247
  node = ast.parse(src)
246
248
 
247
-
248
-
249
- Transformer().visit(node)
249
+ node = Transformer().visit(node)
250
-
250
+
251
- ast.fix_missing_locations(node)
251
+ node = ast.fix_missing_locations(node)
252
252
 
253
253
 
254
254
 
@@ -294,8 +294,12 @@
294
294
 
295
295
 
296
296
 
297
+
298
+
297
299
  if __name__ == '__main__':
298
300
 
299
301
  main()
300
302
 
303
+
304
+
301
- ```
305
+ ```