Why does
any(['','foo'])
raise the exception
TypeError: cannot perform reduce with flexible type
I thought it should evaluate to True
, because
bool('')
evaluates to False
bool('foo')
evaluates to True
any()
could be used with any sequence of objects that are convertible to bool
I'm using Python 2.7.
You are accidentally calling numpy.any()
instead of the built-in any()
. The latter does work for your example.
To fix this, you need to sort out the imports. Look for from numpy import *
and from numpy import any
, and for similar imports involving scipy
and pylab
.