def basicFormat(x):
"""Given an AST, turn it into its value if it's constant; otherwise, leave it alone"""
if type(x) == ast.Num:
return x.n
elif type(x) == ast.NameConstant:
return x.value
elif type(x) == ast.Str:
return x.s
elif type(x) == ast.Bytes:
return x.s
return x # Do not change if it's not a constant!
评论列表
文章目录