def split_host_and_port(netloc):
 match = re.match('^(.+):(\\d+)$', netloc)
 if match:
  host = match.group(1)
  port = int(match.group(2))
 else:
  host = netloc
  port = None
 return (host, port)

def split_host_and_port ( netloc ) : match = re . match ( '^(.+):(\\d+)$' , netloc ) if match : host = match . group ( 1 ) port = int ( match . group ( 2 ) ) else : host = netloc port = None return ( host , port )
returns tuple from netloc .