traceParseAction() AttributeError: no attribute 'func_name'
Brought to you by:
ptmcg
Hi,
I've been trying to use the traceParseAction decorator, but kept getting AttributeErrors. I finally tried running the example code listed in the traceParseAction function Docstring:
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"))
But still got AttributeErrors:
C:\Users\xxxxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyparsing.py in z(*paArgs) 3097 f = _trim_arity(f) 3098 def z(*paArgs): -> 3099 thisFunc = f.func_name 3100 s,l,t = paArgs[-3:] 3101 if len(paArgs)>3: AttributeError: 'function' object has no attribute 'func_name'
Incidentally, there's a missing close parenthesis in the example's return statement as well.
I've tried other example scripts for traceParseAction I've found online but keep getting the same error. I'm running Python 3.5 in Anaconda 3 on a Windows 11 machine.
Any ideas on what's happening?
Thanks!
Tom
You are using an old version of pyparsing - this was fixed in version 2.1.4, released in May, 2016.
Good catch on the missing ')' though, thanks!
Ah, I could have sworn I installed the newest version when I reinstalled my Anaconda suite! I'll reinstall and retry it, thanks!
And as many have said, great module and support!