Menu

#103 traceParseAction() AttributeError: no attribute 'func_name'

v1.0 (example)
closed-fixed
nobody
5
2018-03-31
2017-10-01
Tom V
No

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

Discussion

  • Paul McGuire

    Paul McGuire - 2017-10-04

    You are using an old version of pyparsing - this was fixed in version 2.1.4, released in May, 2016.

     
  • Paul McGuire

    Paul McGuire - 2017-10-04

    Good catch on the missing ')' though, thanks!

     
  • Tom V

    Tom V - 2017-10-04

    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!

     
  • Paul McGuire

    Paul McGuire - 2018-03-31
    • status: open --> closed-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.