本文整理汇总了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)])