def split_symbols_custom(predicate):
 def _split_symbols(tokens, local_dict, global_dict):
  result = []
  split = False
  split_previous = False
  for tok in tokens:
   if split_previous:
    split_previous = False
    continue
   split_previous = False
   if ((tok[0] == NAME) and (tok[1] == 'Symbol')):
    split = True
   elif (split and (tok[0] == NAME)):
    symbol = tok[1][1:(-1)]
    if predicate(symbol):
     for char in symbol:
      if ((char in local_dict) or (char in global_dict)):
       del result[(-2):]
       result.extend([(NAME, ('%s' % char)), (NAME, 'Symbol'), (OP, '(')])
      else:
       result.extend([(NAME, ("'%s'" % char)), (OP, ')'), (NAME, 'Symbol'), (OP, '(')])
     del result[(-2):]
     split = False
     split_previous = True
     continue
    else:
     split = False
   result.append(tok)
  return result
 return _split_symbols

def split_symbols_custom ( predicate ) : def _split_symbols ( tokens , local_dict , global_dict ) : result = [ ] split = False split_previous = False for tok in tokens : if split_previous : split_previous = False continue split_previous = False if ( ( tok [ 0 ] == NAME ) and ( tok [ 1 ] == 'Symbol' ) ) : split = True elif ( split and ( tok [ 0 ] == NAME ) ) : symbol = tok [ 1 ] [ 1 : ( - 1 ) ] if predicate ( symbol ) : for char in symbol : if ( ( char in local_dict ) or ( char in global_dict ) ) : del result [ ( - 2 ) : ] result . extend ( [ ( NAME , ( '%s' % char ) ) , ( NAME , 'Symbol' ) , ( OP , '(' ) ] ) else : result . extend ( [ ( NAME , ( "'%s'" % char ) ) , ( OP , ')' ) , ( NAME , 'Symbol' ) , ( OP , '(' ) ] ) del result [ ( - 2 ) : ] split = False split_previous = True continue else : split = False result . append ( tok ) return result return _split_symbols
creates a transformation that splits symbol names .