On Wed, 21 Dec 2005 16:39:19 +0100, Daniel Schüle wrote: > [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
This is just a thought experiment, right, to see how slow you can make your Python program run? *smiles* Jamie Zawinski: "Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems." -- Steven. -- http://mail.python.org/mailman/listinfo/python-list