(predicate)
return _split_symbols
Creates a transformation that splits symbol names.

    ``predicate`` should return True if the symbol name is to be split.

    For instance, to retain the default behavior but avoid splitting certain
    symbol names, a predicate like this would work:


    >>> from sympy.parsing.sympy_parser import (parse_expr, _token_splittable,
    ... standard_transformations, implicit_multiplication,
    ... split_symbols_custom)
    >>> def can_split(symbol):
    ...     if symbol not in ('list', 'of', 'unsplittable', 'names'):
    ...             return _token_splittable(symbol)
    ...     return False
    ...
    >>> transformation = split_symbols_custom(can_split)
    >>> parse_expr('unsplittable', transformations=standard_transformations +
    ... (transformation, implicit_multiplication))
    unsplittable
Creates a transformation that splits symbol names.
Creates a transformation that splits symbol names .
def split_symbols_custom(predicate):
    """Creates a transformation that splits symbol names.

    ``predicate`` should return True if the symbol name is to be split.

    For instance, to retain the default behavior but avoid splitting certain
    symbol names, a predicate like this would work:


    >>> from sympy.parsing.sympy_parser import (parse_expr, _token_splittable,
    ... standard_transformations, implicit_multiplication,
    ... split_symbols_custom)
    >>> def can_split(symbol):
    ...     if symbol not in ('list', 'of', 'unsplittable', 'names'):
    ...             return _token_splittable(symbol)
    ...     return False
    ...
    >>> transformation = split_symbols_custom(can_split)
    >>> parse_expr('unsplittable', transformations=standard_transformations +
    ... (transformation, implicit_multiplication))
    unsplittable
    """
    def _split_symbols(tokens, local_dict, global_dict):
        result = []
        split = False
        for tok in tokens:
            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:
                            # Get rid of the call to Symbol
                            del result[-2:]
                            result.extend([(OP, '('), (NAME, "%s" % char), (OP, ')'),
                                           (NAME, 'Symbol'), (OP, '(')])
                        else:
                            result.extend([(NAME, "'%s'" % char), (OP, ')'),
                                           (NAME, 'Symbol'), (OP, '(')])
                    # Delete the last three tokens: get rid of the extraneous
                    # Symbol( we just added, and also get rid of the last )
                    # because the closing parenthesis of the original Symbol is
                    # still there
                    del result[-3:]
                    split = False
                    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 for tok in tokens : 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 : # Get rid of the call to Symbol del result [ - 2 : ] result . extend ( [ ( OP , '(' ) , ( NAME , "%s" % char ) , ( OP , ')' ) , ( NAME , 'Symbol' ) , ( OP , '(' ) ] ) else : result . extend ( [ ( NAME , "'%s'" % char ) , ( OP , ')' ) , ( NAME , 'Symbol' ) , ( OP , '(' ) ] ) # Delete the last three tokens: get rid of the extraneous # Symbol( we just added, and also get rid of the last ) # because the closing parenthesis of the original Symbol is # still there del result [ - 3 : ] split = False continue else : split = False result . append ( tok ) return result return _split_symbols