def join_host_strings(user, host, port=None):
 if port:
  template = ('%s@[%s]:%s' if (host.count(':') > 1) else '%s@%s:%s')
  return (template % (user, host, port))
 else:
  return ('%s@%s' % (user, host))

def join_host_strings ( user , host , port = None ) : if port : template = ( '%s@[%s]:%s' if ( host . count ( ':' ) > 1 ) else '%s@%s:%s' ) return ( template % ( user , host , port ) ) else : return ( '%s@%s' % ( user , host ) )
turns user/host/port strings into user@host:port combined string .