Python's socket module provides socket.gethostbyname(hostname) specifically to resolve a hostname such as www.giac.org into its IPv4 address, returning the address as a dotted-quad string. This is distinct from socket.gethostbyaddr(), which performs the reverse operation of mapping an IP address back to a hostname, and there is no socket.nslookup or socket.get function in the standard library. Of the offered options, only the one built around the gethostbyname-style call correctly represents the mechanism used to obtain an IP address from a hostname.
Community Discussion