python pyparsing word excludeChars
Question: I am trying to make a parser for a number which can contain an '_'. I would
like the underscore to be suppressed in the output. For example, a valid word
would be 1000_000 which should return a number: 1000000. I have tried the
excludeChars keyword argument for this as _my understanding_ is that this
should do the following:

> "If supplied, this argument specifies characters not to be considered to
> match, even if those characters are otherwise considered to match."

Taken from <http://infohost.nmt.edu/tcc/help/pubs/pyparsing/pyparsing.pdf> \-
page 33 section 5.35 (great pyparsing reference btw)

So below is my attempt:

    
    
    import pyparsing as pp
    num = pp.Word(pp.nums+'_', excludeChars='_')
    num.parseString('123_4')
    

but I end up with the result '123' instead of '1234'

    
    
    In [113]: num.parseString('123_4')
    Out[113]: (['123'], {})
    

Any suggestions?


Answer: How about simply replacing the underscore char?

    
    
    "123_4".replace("_", "")
    # "1234"
    

