Pythonic way to determine if a string is a number

Roy Smith roy at panix.com
Sun Feb 15 13:15:38 EST 2009


In article <mailman.9571.1234720024.3487.python-list at python.org>,
 python at 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(myString)
except ValueError:
   print "That's bogus, man"



More information about the Python-list mailing list