本文整理匯總了Python中symbol.and_test方法的典型用法代碼示例。如果您正苦於以下問題:Python symbol.and_test方法的具體用法?Python symbol.and_test怎麽用?Python symbol.and_test使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類symbol
的用法示例。
在下文中一共展示了symbol.and_test方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_op
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import and_test [as 別名]
def get_op(cls, op):
ops = {
symbol.test: cls.test,
symbol.and_test: cls.and_test,
symbol.atom: cls.atom,
symbol.comparison: cls.comparison,
'not in': lambda x, y: x not in y,
'in': lambda x, y: x in y,
'==': operator.eq,
'!=': operator.ne,
'<': operator.lt,
'>': operator.gt,
'<=': operator.le,
'>=': operator.ge,
}
if hasattr(symbol, 'or_test'):
ops[symbol.or_test] = cls.test
return ops[op]
示例2: and_test
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import and_test [as 別名]
def and_test(cls, nodelist):
# MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
items = [
cls.interpret(nodelist[i])
for i in range(1, len(nodelist), 2)
]
return functools.reduce(operator.and_, items)
示例3: get_op
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import and_test [as 別名]
def get_op(cls, op):
ops = {
symbol.test: cls.test,
symbol.and_test: cls.and_test,
symbol.atom: cls.atom,
symbol.comparison: cls.comparison,
'not in': lambda x, y: x not in y,
'in': lambda x, y: x in y,
'==': operator.eq,
'!=': operator.ne,
}
if hasattr(symbol, 'or_test'):
ops[symbol.or_test] = cls.test
return ops[op]
示例4: or_test
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import and_test [as 別名]
def or_test(self, nodelist):
# and_test ('or' and_test)* | lambdef
if len(nodelist) == 1 and nodelist[0][0] == symbol.lambdef:
return self.lambdef(nodelist[0])
return self.com_binary(Or, nodelist)
示例5: and_test
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import and_test [as 別名]
def and_test(self, nodelist):
# not_test ('and' not_test)*
return self.com_binary(And, nodelist)
示例6: and_test
# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import and_test [as 別名]
def and_test(cls, nodelist):
# MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
return functools.reduce(operator.and_, [cls.interpret(nodelist[i]) for i in range(1,len(nodelist),2)])