[EMAIL PROTECTED] wrote:
> How do I check if a string contains (can be converted to) an int? I
> want to do one thing if I am parsing and integer, and another if not.
>
> /David
>
others already answered, this is just an idea
>>> def isNumber(n):
... import re
... if re.match("^[-+]?[0-9]+$", n):
... return True
... return False
does not recognize 0x numbers, but this is easy to fix
if wanted
>>> def isNumber(n):
... import re
... if re.match("^[-+]?[0-9A-Fa-f]+$", n):
... return True
... return False
hth
Daniel
--
http://mail.python.org/mailman/listinfo/python-list