def is_number(s, cast=float):
    """
    Check if a string is a number. Use cast=int to check if s is an integer.
    """
    try:
        cast(s)  # for int, long and float
    except ValueError:
        return False

    return True