I have an arbitrarily sized list:
l = [1, 2, 3, 4, 5, ...]
I want to apply the pipe operator to all items in the list, sequentially, like this:
1 | 2 | 3 | 4 | 5 # = 7
I know there is a function in the stdlib that does this, and that this question is probably a duplicate, but I don’t recall the function and can’t find answer pointing me to it.
>Solution :
You could use functools.reduce in conjunction with operator.or_.
from functools import reduce
import operator
l = [1, 2, 3, 4, 5]
res = reduce(operator.or_, l)
print(res)