import _socket


def resolve(hostname, port=False):
    """
    Resolves hostname to IP address.
    IPv6 addresses get mapped to IPv6 if a port isn't supplied
    returns str(IP_address)
    """
    if port:
        return _socket.getaddrinfo(hostname, port)[0][4][0]
    else:
        return _socket.gethostbyname(hostname)