def is_valid_ext_comm_attr(attr):
 if (not isinstance(attr, str)):
  return False
 tokens = attr.rsplit(':', 1)
 if (len(tokens) != 2):
  return False
 try:
  if ('.' in tokens[0]):
   if (not is_valid_ipv4(tokens[0])):
    return False
  else:
   int(tokens[0])
  int(tokens[1])
 except (ValueError, socket.error):
  return False
 return True

def is_valid_ext_comm_attr ( attr ) : if ( not isinstance ( attr , str ) ) : return False tokens = attr . rsplit ( ':' , 1 ) if ( len ( tokens ) != 2 ) : return False try : if ( '.' in tokens [ 0 ] ) : if ( not is_valid_ipv4 ( tokens [ 0 ] ) ) : return False else : int ( tokens [ 0 ] ) int ( tokens [ 1 ] ) except ( ValueError , socket . error ) : return False return True
validates *attr* as string representation of rt or soo .