def generate_io_stmt(input_idx, var_name, value, func_name):
if value is None:
return []
elif isinstance(value, list):
return [ast.Expr(
ast.Call(
ast.Attribute(
ast.Subscript(
ast.Name(var_name, ast.Load()),
ast.Index(
ast.Tuple([ast.Num(input_idx),
ast.Num(val_idx)],
ast.Load())),
ast.Load()),
func_name,
ast.Load()),
[ast.Num(val)],
[], None, None))
for val_idx, val in enumerate(value)
if val is not None]
else:
return [ast.Expr(
ast.Call(
ast.Attribute(
ast.Subscript(
ast.Name(var_name, ast.Load()),
ast.Index(ast.Num(input_idx)),
ast.Load()),
func_name,
ast.Load()),
[ast.Num(value)],
[], None, None))]
评论列表
文章目录