def is_valid_ip(ip):
    try:
        if is_ipv4(ip):
            a = ip.split('.')
            assert len(a) == 4
            for i in a:
                chr(int(i))
            return True
        to_long_ipv6(ip)
        return True
    except:
        return False
dataset/ETHPy150Open Cclleemm/FriendlyTorrent/src/tornado/BitTornado/iprangeparse.py/is_valid_ip/original