the.lo...@gmail.com writes:

> Given the following code:
>
> import ipaddress
> import socket
>
> ip = ipaddress.ip_address(mystring)
> sock_family = ip.????
> socket = socket.socket(sock_family, socket.SOCK_STREAM)
>
> Am I crazy or is this undoable?
>
> sock.AF_INET == 2
> sock.AF_INET6 == 10
> ip.version == 4 or 6

Check the value of the "version" attribute. Or use socket.getaddrinfo(),
which is more convenient if all you need is an address parser.

-- Alain.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to