def traceParseAction(f):
f = _trim_arity(f)<EOL>def z(*paArgs):<EOL><INDENT>thisFunc = f.__name__<EOL>s,l,t = paArgs[-<NUM_LIT:3>:]<EOL>if len(paArgs)><NUM_LIT:3>:<EOL><INDENT>thisFunc = paArgs[<NUM_LIT:0>].__class__.__name__ + '<STR_LIT:.>' + thisFunc<EOL><DEDENT>sys.stderr.write( "<STR_LIT>" % (thisFunc,line(l,s),l,t) )<EOL>try:<EOL><INDENT>ret = f(*paArgs)<EOL><DEDENT>except Exception as exc:<EOL><INDENT>sys.stderr.write( "<STR_LIT>" % (thisFunc,exc) )<EOL>raise<EOL><DEDENT>sys.stderr.write( "<STR_LIT>" % (thisFunc,ret) )<EOL>return ret<EOL><DEDENT>try:<EOL><INDENT>z.__name__ = f.__name__<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>return z<EOL>
Decorator for debugging parse actions.

    When the parse action is called, this decorator will print
    ``">> entering method-name(line:<current_source_line>, <parse_location>, <matched_tokens>)"``.
    When the parse action completes, the decorator will print
    ``"<<"`` followed by the returned value, or any exception that the parse action raised.

    Example::

        wd = Word(alphas)

        @traceParseAction
        def remove_duplicate_chars(tokens):
            return ''.join(sorted(set(''.join(tokens))))

        wds = OneOrMore(wd).setParseAction(remove_duplicate_chars)
        print(wds.parseString("slkdjs sld sldd sdlf sdljf"))

    prints::

        >>entering remove_duplicate_chars(line: 'slkdjs sld sldd sdlf sdljf', 0, (['slkdjs', 'sld', 'sldd', 'sdlf', 'sdljf'], {}))
        <<leaving remove_duplicate_chars (ret: 'dfjkls')
        ['dfjkls']