def is_valid_ipv6(ip_str):
    try:
        socket.inet_pton(socket.AF_INET6, ip_str)
    except socket.error:
        return False
    return True
Check the validity of an IPv6 address
dataset/ETHPy150Open un33k/django-ipware/ipware/utils.py/is_valid_ipv6