def partition_node(node):
 host = node
 port = 27017
 idx = node.rfind(':')
 if (idx != (-1)):
  (host, port) = (node[:idx], int(node[(idx + 1):]))
 if host.startswith('['):
  host = host[1:(-1)]
 return (host, port)

def partition_node ( node ) : host = node port = 27017 idx = node . rfind ( ':' ) if ( idx != ( - 1 ) ) : ( host , port ) = ( node [ : idx ] , int ( node [ ( idx + 1 ) : ] ) ) if host . startswith ( '[' ) : host = host [ 1 : ( - 1 ) ] return ( host , port )
split a host:port string into (host .