def mk_operator(which):
ops = {'+':operator.add, '-':operator.sub, '*':operator.mul, '/':operator.truediv, '^':operator.pow,
'&&': operator.and_, '||': operator.or_, '!':operator.not_,
'and': operator.and_, 'or': operator.or_, 'not':operator.not_,
'in': lambda x, y: operator.contains(y, x), '=':operator.eq,
'<': operator.lt, '<=':operator.le, '>=':operator.ge, '>':operator.gt }
return ops[which]
# Token makers
评论列表
文章目录