def parse_host_port ( host_port ) : host , port = urllib . splitport ( host_port . strip ( ) ) if port is not None : if urlutil . is_numeric_port ( port ) : port = int ( port ) return host , port
python parse ip and port
Parse a host : port string into separate components .
def parse_host_port (host_port):
    """Parse a host:port string into separate components."""
    host, port = urllib.splitport(host_port.strip())
    if port is not None:
        if urlutil.is_numeric_port(port):
            port = int(port)
    return host, port