is there a binary OR operator in python that works on arrays?
问题 I have come from a matlab background to python and i am just wondering if there is a simple operator in python that will perform the following function: a = [1, 0, 0, 1, 0, 0] b = [0, 1, 0, 1, 0, 1] c = a|b print c [1, 1, 0, 1, 0, 1] or would i have to write a separate function to do that? 回答1: You could use a list comprehension. Use izip from itertools if you're using Python 2. c = [x | y for x, y in zip(a, b)] Alternatively, @georg pointed out in a comment that you can import the bitwise or