def split_netloc(netloc):
    """Split netloc into username, password, host and port.

    >>> split_netloc('foo:bar@www.example.com:8080')
    ('foo', 'bar', 'www.example.com', '8080')
    """
    username = password = host = port = ''
    if '@' in netloc:
        user_pw, netloc = netloc.split('@', 1)
        if ':' in user_pw:
            username, password = user_pw.split(':', 1)
        else:
            username = user_pw
    netloc = _clean_netloc(netloc)
    if ':' in netloc and netloc[-1] != ']':
        host, port = netloc.rsplit(':', 1)
    else:
        host = netloc
    return username, password, host, port
def split_netloc ( netloc ) : username = password = host = port = '' if '@' in netloc : user_pw , netloc = netloc . split ( '@' , 1 ) if ':' in user_pw : username , password = user_pw . split ( ':' , 1 ) else : username = user_pw netloc = _clean_netloc ( netloc ) if ':' in netloc and netloc [ - 1 ] != ']' : host , port = netloc . rsplit ( ':' , 1 ) else : host = netloc return username , password , host , port
Split netloc into username, password, host and port.

    >>> split_netloc('foo:bar@www.example.com:8080')
    ('foo', 'bar', 'www.example.com', '8080')