def split_host(srv):
 mark = srv.rfind(':')
 if (mark < 0):
  host = srv
 else:
  host = srv[0:mark]
  port = srv[(mark + 1):]
 try:
  port = int(port)
 except:
  port = None
 return (host, port)

def split_host ( srv ) : mark = srv . rfind ( ':' ) if ( mark < 0 ) : host = srv else : host = srv [ 0 : mark ] port = srv [ ( mark + 1 ) : ] try : port = int ( port ) except : port = None return ( host , port )
split host:port notation .