def _is_None(node):
#
# for some reason,
#
# > ast.dump(ast.parse(x[0:1:]))
# Module(body=[Expr(value=Subscript(value=Name(id='x', ctx=Load()),
# slice=Slice(lower=Num(n=0), upper=None,
# step=Name(id='None', ctx=Load())), ctx=Load()))])
#
# notice that the step value is not 'None' but the Name that contains 'None'.
# Need to special case this.
#
return node is None or (isinstance(node, ast.Name) and node.id == 'None')
评论列表
文章目录