我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用ast.Delete()。
def get_coverable_nodes(cls): return { ast.Assert, ast.Assign, ast.AugAssign, ast.Break, ast.Continue, ast.Delete, ast.Expr, ast.Global, ast.Import, ast.ImportFrom, ast.Nonlocal, ast.Pass, ast.Raise, ast.Return, ast.FunctionDef, ast.ClassDef, ast.TryExcept, ast.TryFinally, ast.ExceptHandler, ast.If, ast.For, ast.While, }
def get_coverable_nodes(cls): return { ast.Assert, ast.Assign, ast.AugAssign, ast.Break, ast.Continue, ast.Delete, ast.Expr, ast.Global, ast.Import, ast.ImportFrom, ast.Nonlocal, ast.Pass, ast.Raise, ast.Return, ast.ClassDef, ast.FunctionDef, ast.Try, ast.ExceptHandler, ast.If, ast.For, ast.While, }
def isStatement(a): """Determine whether the given node is a statement (vs an expression)""" return type(a) in [ ast.Module, ast.Interactive, ast.Expression, ast.Suite, ast.FunctionDef, ast.ClassDef, ast.Return, ast.Delete, ast.Assign, ast.AugAssign, ast.For, ast.While, ast.If, ast.With, ast.Raise, ast.Try, ast.Assert, ast.Import, ast.ImportFrom, ast.Global, ast.Expr, ast.Pass, ast.Break, ast.Continue ]
def test_delete(self): self.stmt(ast.Delete([]), "empty targets on Delete") self.stmt(ast.Delete([None]), "None disallowed") self.stmt(ast.Delete([ast.Name("x", ast.Load())]), "must have Del context")
def infer(node, context, solver): if isinstance(node, ast.Assign): return _infer_assign(node, context, solver) elif isinstance(node, ast.AugAssign): return _infer_augmented_assign(node, context, solver) elif isinstance(node, ast.Return): if not node.value: return solver.z3_types.none return expr.infer(node.value, context, solver) elif isinstance(node, ast.Delete): return _infer_delete(node, context, solver) elif isinstance(node, (ast.If, ast.While)): return _infer_control_flow(node, context, solver) elif isinstance(node, ast.For): return _infer_for(node, context, solver) elif sys.version_info[0] >= 3 and sys.version_info[1] >= 5 and isinstance(node, ast.AsyncFor): # AsyncFor is introduced in Python 3.5 return _infer_for(node, context, solver) elif isinstance(node, ast.With): return _infer_with(node, context, solver) elif sys.version_info[0] >= 3 and sys.version_info[1] >= 5 and isinstance(node, ast.AsyncWith): # AsyncWith is introduced in Python 3.5 return _infer_with(node, context, solver) elif isinstance(node, ast.Try): return _infer_try(node, context, solver) elif isinstance(node, ast.FunctionDef): return _infer_func_def(node, context, solver) elif isinstance(node, ast.ClassDef): return _infer_class_def(node, context, solver) elif isinstance(node, ast.Expr): expr.infer(node.value, context, solver) elif isinstance(node, ast.Import): return _infer_import(node, context, solver) elif isinstance(node, ast.ImportFrom): return _infer_import_from(node, context, solver) return solver.z3_types.none