def pos_int(i):
    """ Simple positive integer validation. """
    try:
        if isinstance(i, string_types):
            i = int(i)
        if not isinstance(i, int) or i < 0:
            raise Exception()
    except:
        raise ValueError("Not a positive integer")
    return i
def pos_int ( i ) : try : if isinstance ( i , string_types ) : i = int ( i ) if not isinstance ( i , int ) or i < 0 : raise Exception ( ) except : raise ValueError ( "Not a positive integer" ) return i
Simple positive integer validation.