Why is operator module missing `and` and `or`?
问题 operator module makes it easy to avoid unnecessary functions and lambdas in situations like this: import operator def mytest(op, list1, list2): ok = [op(i1, i2) for i1, i2 in zip(list1, list2)] return all(ok) mytest(operator.eq, [1, 2, 3], [1, 2, 3]) # True mytest(operator.add, [-1, 2, -3], [1, -2, 33]) # False Well, now I need to do i1 and i2 , but to my surprise, I can't find and in the operator module! And the same applies to or ! I know, and is not exactly operator , it's a keyword , but