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