Tim Williams wrote:
> On 04/09/06, Dr. Pastor <[EMAIL PROTECTED]> wrote:
>> In the following code I would like to ascertain
>> that x has/is a number. What the simplest TEST should be?

def isnumber(value):
    try:
        value/1
        return true
    except TypeError:
        return false

I think this works for all builtin types. Of course one could
overload '/' for a non-numeric class. The best solution would
be to introduce a super class base_number for int, long, float
and decimal, similar to base_string for str and unicode.

This would probably be not too hard to implement and surely not
break old code :)

Peter Maas, Aachen
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to