(ipname)
Try to convert an IP address to packed binary form

    Supports IPv4 addresses on all platforms and IPv6 on platforms with IPv6
    support.
Try to convert an IP address to packed binary form
Try to convert an IP address to packed binary form
def _inet_paton(ipname):
    """Try to convert an IP address to packed binary form

    Supports IPv4 addresses on all platforms and IPv6 on platforms with IPv6
    support.
    """
    # inet_aton() also accepts strings like '1', '127.1', some also trailing
    # data like '127.0.0.1 whatever'.
    try:
        addr = _socket.inet_aton(ipname)
    except OSError:
        # not an IPv4 address
        pass
    else:
        if _socket.inet_ntoa(addr) == ipname:
            # only accept injective ipnames
            return addr
        else:
            # refuse for short IPv4 notation and additional trailing data
            raise ValueError(
                "{!r} is not a quad-dotted IPv4 address.".format(ipname)
            )

    try:
        return _socket.inet_pton(_socket.AF_INET6, ipname)
    except OSError:
        raise ValueError("{!r} is neither an IPv4 nor an IP6 "
                         "address.".format(ipname))
    except AttributeError:
        # AF_INET6 not available
        pass

    raise ValueError("{!r} is not an IPv4 address.".format(ipname))
def _inet_paton ( ipname ) : # inet_aton() also accepts strings like '1', '127.1', some also trailing # data like '127.0.0.1 whatever'. try : addr = _socket . inet_aton ( ipname ) except OSError : # not an IPv4 address pass else : if _socket . inet_ntoa ( addr ) == ipname : # only accept injective ipnames return addr else : # refuse for short IPv4 notation and additional trailing data raise ValueError ( "{!r} is not a quad-dotted IPv4 address." . format ( ipname ) ) try : return _socket . inet_pton ( _socket . AF_INET6 , ipname ) except OSError : raise ValueError ( "{!r} is neither an IPv4 nor an IP6 " "address." . format ( ipname ) ) except AttributeError : # AF_INET6 not available pass raise ValueError ( "{!r} is not an IPv4 address." . format ( ipname ) )