Re: [Pyparsing] Grouping when using asList()
Brought to you by:
ptmcg
From: Paul M. <pt...@au...> - 2008-03-07 14:06:50
|
Oooh, I'm *tempted*, so tempted. What do you think of Joshua's proposal of passing through the **kw dict? It's a little more explicit without requiring the full ".setResultsName" syntax. Side-by-side, the options are: A) date = twoDigitInt("month*") + '/' + twoDigitInt("day") B) date = twoDigitInt("month", listAllMatches=True) + '/' + twoDigitInt("day") I could go either way. Just for the sake of alternatives, I tried some other string-based indicators: C) date = twoDigitInt("month!") + '/' + twoDigitInt("day") D) date = twoDigitInt("month+") + '/' + twoDigitInt("day") E) date = twoDigitInt("[month]") + '/' + twoDigitInt("day") F) date = twoDigitInt("{month}") + '/' + twoDigitInt("day") but I'm not compelled to use any of these over '*'. 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. Any other comments from others on the list? -- Paul -----Original Message----- From: pyp...@li... [mailto:pyp...@li...] On Behalf Of Ralph Corderoy Sent: Friday, March 07, 2008 4:07 AM To: pyp...@li... Subject: Re: [Pyparsing] Grouping when using asList() Hi Paul, > date = twoDigitInt("month") + '/' + twoDigitInt("day") + '/' + > twoDigitInt("year") > > Try to look past the "it's a function call" to "this is a lot easier > to specify a results name than that old way!". (However, if you need > to add the listAllMatches attribute, this still requires the explicit > call to setResultsName.) How about signifying in the string that listAllMatches should be true, e.g. 'month*'? Cheers, Ralph. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Pyparsing-users mailing list Pyp...@li... https://lists.sourceforge.net/lists/listinfo/pyparsing-users |