本文整理汇总了Python中compiler.ast.Discard方法的典型用法代码示例。如果您正苦于以下问题:Python ast.Discard方法的具体用法?Python ast.Discard怎么用?Python ast.Discard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类compiler.ast
的用法示例。
在下文中一共展示了ast.Discard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CheckedEval
# 需要导入模块: from compiler import ast [as 别名]
# 或者: from compiler.ast import Discard [as 别名]
def CheckedEval(file_contents):
"""Return the eval of a gyp file.
The gyp file is restricted to dictionaries and lists only, and
repeated keys are not allowed.
Note that this is slower than eval() is.
"""
ast = compiler.parse(file_contents)
assert isinstance(ast, Module)
c1 = ast.getChildren()
assert c1[0] is None
assert isinstance(c1[1], Stmt)
c2 = c1[1].getChildren()
assert isinstance(c2[0], Discard)
c3 = c2[0].getChildren()
assert len(c3) == 1
return CheckNode(c3[0], [])
示例2: _isNativeFunc
# 需要导入模块: from compiler import ast [as 别名]
# 或者: from compiler.ast import Discard [as 别名]
def _isNativeFunc(self, node):
if isinstance(node, ast.Discard):
if isinstance(node.expr, ast.CallFunc):
if isinstance(node.expr.node, ast.Name) and \
node.expr.node.name == NATIVE_JS_FUNC_NAME:
return True
return False