Steven Bethard wrote:Is there a good way to determine if an object is a numeric type?
assert operator.isNumberType(i)
Interesting, thanks! If I read the source right, PyNumber_Check (which operator.isNumberType is an alias for) basically just returns True if the object's type has a __int__ or __float__ method defined:
int
PyNumber_Check(PyObject *o)
{
return o && o->ob_type->tp_as_number &&
(o->ob_type->tp_as_number->nb_int ||
o->ob_type->tp_as_number->nb_float);
}Did I read that right?
Steve -- http://mail.python.org/mailman/listinfo/python-list
