How to find/detect if a build-in function is used in Python AST?
问题 The goal is to detect if a builtin function such as eval() is used in some code. def foo(a): eval('a = 2') I have tried the following approach: ex_ast = ast.parse(inspect.getsource(foo)) for node in ast.walk(ex_ast): if isinstance(node, ast.FunctionDef): print(node.name) The function name foo is printed as the output. I know that Builtin functions don't have constructors. They are in the type Module. So 1 approach would be using types.FunctionType in an isinstance call. But since I'm using