本文整理匯總了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