def splitnport(host, defport=(-1)):
 global _nportprog
 if (_nportprog is None):
  _nportprog = re.compile('^(.*):(.*)$')
 match = _nportprog.match(host)
 if match:
  (host, port) = match.group(1, 2)
  if port:
   try:
    nport = int(port)
   except ValueError:
    nport = None
   return (host, nport)
 return (host, defport)

def splitnport ( host , defport = ( - 1 ) ) : global _nportprog if ( _nportprog is None ) : _nportprog = re . compile ( '^(.*):(.*)$' ) match = _nportprog . match ( host ) if match : ( host , port ) = match . group ( 1 , 2 ) if port : try : nport = int ( port ) except ValueError : nport = None return ( host , nport ) return ( host , defport )
split host and port .