On Sat, Oct 15, 2011 at 12:44 AM, MrPink <tdsimp...@gmail.com> wrote: > > Is there a function in Python that can be used to test if the value in > a string is an integer? I had to make one up for myself and it looks > like this: > > def isInt(s): > try: > i = int(s) > return True > except ValueError: > return False
There's the isdigit method, for example - >>> str = "1324325" >>> str.isdigit() True >>> str = "1232.34" >>> str.isdigit() False >>> str = "I am a string, not an int!" >>> str.isdigit() False -- http://mail.python.org/mailman/listinfo/python-list