check if object is number

Michael Hartl mhartl at post.harvard.edu
Fri Feb 11 18:22:50 EST 2005


As I mention below, I mistook the function from my utilities file for a
Python built-in; here's the implementation:

#def isnumber(x):
#    "Is x a number? We say it is if it has an __int__ method."
#    return hasattr(x, '__int__')




More information about the Python-list mailing list