Are there builtin functions for elementwise boolean operators over boolean lists? Are there builtin functions for elementwise boolean operators over boolean lists? python python

Are there builtin functions for elementwise boolean operators over boolean lists?


There is not a built-in way to do this. Generally speaking, list comprehensions and the like are how you do elementwise operations in Python.

Numpy does provide this (using &, for technical limitations) in its array type. Numpy arrays usually perform operations elementwise.


The numpy.all function does what you want, if you specify the dimension to collapse on:

>>> all([[True, False, True, False, True], [True, True, False, False, True], [True, True, False, False, True]], 0)array([ True, False, False, False,  True], dtype=bool)