Bill Mill wrote:
On Fri, 11 Feb 2005 12:11:44 -0700, Steven Bethard
<[EMAIL PROTECTED]> wrote:

Is there a good way to determine if an object is a numeric type?

How about:
if type(variable) == type(1):
print "is an integer"
else:
print "please input an integer"

This checks if it is an integer, not if it is a numeric type:

py> x = 1
py> type(x) == type(1)
True
py> # using int instead of type(1)
py> type(x) == int
True
py> x = 1.0
py> type(x) == int
False

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

Reply via email to