Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setResultsName in version 3.1.1 destroys previous resultnames. #506

Open
nilsw1 opened this issue Aug 3, 2023 · 0 comments
Open

setResultsName in version 3.1.1 destroys previous resultnames. #506

nilsw1 opened this issue Aug 3, 2023 · 0 comments

Comments

@nilsw1
Copy link

nilsw1 commented Aug 3, 2023

I am trying to migrate from version 2.4.5 to 3.1.1 but encounter problems with setResultsName and listAllMatches=True. Is this due to an old error as in #429? That would be unfortunate because I have used this facility extensively. Simplified example:

from pyparsing import  Word, alphas, nums, Optional, delimitedList
import pyparsing
print('pyparsing.version =', pyparsing.__version__)
ident = Word(alphas)
num = Word(nums)
term = (ident('vars*') | num('const*'))('terms*')
func = ident("function_name") + '(' + Optional(delimitedList(term))("args*") + ')'
parsed = func.parseString("fn(a, b, 100)")
print('args =',  parsed.args.asList())
print('terms =', parsed.terms)
print('vars =', parsed.vars)
print('const =', parsed.const)

Gives the following result:

pyparsing.version = 3.1.1
args = [['a', 'b', '100']]
terms = 100
vars = b
const = 100

terms should be the same list as args. In this case I can obviously use args but in more complex cases it could be a subset which is valuable to have.

vars should be the list ['a', 'b'].

In version 2.4.5 I get:

pyparsing245.version = 2.4.5
args = [['a', 'b', '100']]
terms = ['a', 'b', '100']
vars = ['a', 'b']
const = ['100']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant