Hullo
I'm using 1.5.0, so it's possible that the world has changed.
I'm parsing some email logs and wanted to use a common chunk of grammar for picking out the email addresses. However, when I used a naive piece of code, I found that I seem to have singleton instances of whatever the parse grammar class is called:
If I name the node for the 'from' address (as above), I get an output of:
from
to
[['from=', 'a', 'to=', 'b']]
However, if I don't name the node, the output looks like this:
to
to
[['from=', 'a', 'to=', 'b']]
Looking at pyparsing.py, I think that the implicit call to setResultsName causes the ParseResult (?) instance to be copied, so that the second call to setParseAction doesn't overwrite the first method call. I *think* that all instances ought to be copies, otherwise this is quite an easy error to make, and non-trivial to pick out. Has the behaviour changed and am I right in thinking that the 'named' behaviour ought to happen for non-named nodes too?
feedback gratefully received.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hullo
I'm using 1.5.0, so it's possible that the world has changed.
I'm parsing some email logs and wanted to use a common chunk of grammar for picking out the email addresses. However, when I used a naive piece of code, I found that I seem to have singleton instances of whatever the parse grammar class is called:
If I name the node for the 'from' address (as above), I get an output of:
However, if I don't name the node, the output looks like this:
Looking at pyparsing.py, I think that the implicit call to setResultsName causes the ParseResult (?) instance to be copied, so that the second call to setParseAction doesn't overwrite the first method call. I *think* that all instances ought to be copies, otherwise this is quite an easy error to make, and non-trivial to pick out. Has the behaviour changed and am I right in thinking that the 'named' behaviour ought to happen for non-named nodes too?
feedback gratefully received.