hmm, little question here from a slightly new user.

Alex alex at somewhere.round.here
Thu Mar 23 18:57:46 EST 2000


from types import StringType, IntType

def is_int (n):
    if type (n) == StringType:
        try:
            int (n)
        except ValueError:
            return 0
        else:
            return 1
    else:
        return type (n) == IntType

if __name__ == '__main__':
    print is_int (0)
    print is_int (5.4)
    print is_int ('Hi there')
    

Hope this helps.
Alex.



More information about the Python-list mailing list