import socket


def str_to_inet(str):
    """Convert string object to an inet

    :param str: printable/readable IP address
    :type str: str
    :return: inet (inet struct) - an inet network address
    """
    try:
        return socket.inet_pton(socket.AF_INET, str)
    except ValueError:
        return socket.inet_pton(socket.AF_INET6, str)