Peter Hansen wrote:
Of course, most of the other definitions of "is a number" that
have been posted may likewise fail (defined as not doing what the
OP would have wanted, in this case) with a numarray arange.
Or maybe not.  (Pretty much all of them will call an arange a
number... would the OP's function work properly with that?)

No, but it will fail properly since my code basically looks like:

def f(max=None):
    ...
    while max is None or n <= max:
        ...
        # complicated incrementing of n

So if max is an array, though all of the proposed isnumber checks will call it a number, my code will (rightly) fail when the array (n <= max) gets __nonzero__ called in the while condition. I guess I'd prefer it to fail in the isnumber check, but overall, I'm more concerned that _some_ error is produced, not necessarily which one. (I'm also not thrilled that bool(array) raises a RuntimeError instead of a TypeError...)

Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to