How to test if object is an integer?

MrPink tdsimpson at gmail.com
Fri Oct 14 19:44:07 EDT 2011


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



More information about the Python-list mailing list