OK. I can't think of a really good use case for using an array as a truth value. I would argue though, that it would make sense for an array of zeros to be False and an array with any non-zero values to be True. Travis Oliphant wrote:
Perry Greenfield wrote:
Essentially, my argument is that this case presents many likely surprises for users and when there isn't one obvious way to do it, it shouldn't be done. I'd argue that not allowing arrays as truth values it is more Pythonic. (Existing arrays don't support rich comparisons, and they are false only when empty, as would be expected).
Right now, I'm leaning towards raising an error. A big explanation for that is the idea that "explicit" is better than "implicit." I'm persuaded by Perry's argument that a casual user is going to think that "and" and "&" have the same behavior for arrays. The experienced user is going to understand the difference, anyway.
So ultimately, I don't really see an impressive use case for returning a truth value for arrays, but I do see a "new-user" issue if an error is not raised.
So, right now in SVN, arrays as truth values raise erros unless the array contains only one element (in which case it is unambiguous).
-Travis
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.net http://www.scipy.net/mailman/listinfo/scipy-dev
-- Steven H. Rogers, Ph.D., steve@shrogers.com Weblog: http://shrogers.com/weblog "He who refuses to do arithmetic is doomed to talk nonsense." -- John McCarthy