Throws an exception if the number starts with a 0 (may be significant).

    If the value cannot be converted to an int, it is returned as is.

def safeInt(n, warn_only=False):
    """Throws an exception if the number starts with a 0 (may be significant).

    If the value cannot be converted to an int, it is returned as is.
    """
    if str(n).startswith('0'):
        if not warn_only:
            raise TypeError("Unsafe Int: " + str(n))
        print "Unsafe Int: %s" % n
        return int(n)
    try:
        return int(n)
    except ValueError:
        return n