def get_auth_from_url(url):
 parsed = urlparse(url)
 try:
  auth = (unquote(parsed.username), unquote(parsed.password))
 except (AttributeError, TypeError):
  auth = ('', '')
 return auth

def get_auth_from_url ( url ) : parsed = urlparse ( url ) try : auth = ( unquote ( parsed . username ) , unquote ( parsed . password ) ) except ( AttributeError , TypeError ) : auth = ( '' , '' ) return auth
given a url with authentication components .