Re: [Pyparsing] Grouping when using asList()
Brought to you by:
ptmcg
From: Joshua J. K. <jk...@sk...> - 2008-03-07 17:53:08
|
On Fri, 2008-03-07 at 08:06 -0600, Paul McGuire wrote: > Oooh, I'm *tempted*, so tempted. Syntactical sugar is *always* tempting, I've found, even when it's something that could come back to bite you later. :) > Mostly I'm concerned about accidental listAllMatches behavior when a results > name is set from within the parsing of a Dict, which is a bit out of the > developer's control - the results names are taken from the input text > stream, and could reasonably contain any of these options. I would (personally) prefer the explicit listAllMatches=True simply because you climb on to very shaky ground when you start introducing special characters...they are kind of like "magic numbers." And then there is the concept of "surprising behavior." If I was reading over someone's code (and was unfamiliar with pyparsing), and I saw 'month*', I might be expecting it to do something like a wildcard match, or some such. The other alternatives seem a bit ambiguous, even if [] does imply putting all the results in an array. Actually, listAllMatches is a bit ambiguous too...keepAllMatches might be a little bit clearer as far as that goes, but that is neither here nor there. So, my vote is to keep the explicitness, both for practical reasons and readability/understanding-the-code reasons. j -- Joshua Kugler VOC/SigNet Provider (aka Web App Programmer) S&K Aerospace Alaska |