On Feb 15, 2009, at 1:27 PM, Christian Heimes wrote:
Philip Semanchuk schrieb:
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
Please don't teach new Python developers to use bare excepts.
Good point; my example is lazy.
I should know better as I myself got burned on bare excepts a few
times when I started with Python.
--
http://mail.python.org/mailman/listinfo/python-list