code: def str_to_inet(address):
      
      # First try ipv4 and then ipv6
      try:
          return socket.inet_pton(socket.AF_INET, address)
      except socket.error:
          return socket.inet_pton(socket.AF_INET6, address)
docs: Convert an a string IP address to a inet struct
  
          Args:
              address (str): String representation of address
          Returns:
              inet: Inet network address