def is_ipv6(addr):
    try:
        socket.inet_pton(socket.AF_INET6, addr)
        return True
    except socket.error:
        return False


# [START example]
Checks if a given address is an IPv6 address.
dataset/ETHPy150Open GoogleCloudPlatform/python-docs-samples/managed_vms/datastore/main.py/is_ipv6