On Feb 15, 2009, at 12:46 PM, pyt...@bdurham.com wrote:

What's the Pythonic way to determine if a string is a number? By
number I mean a valid integer or float.


try:
   int(number)
   is_an_int = True
except:
   is_an_int = False

try:
   float(number)
   is_a_float = True
except:
   is_a_float = False

is_a_number = (is_an_int or is_a_float)


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

Reply via email to