Custom behavior defined in the imported module
Kent Johnson
kent at kentsjohnson.com
Sat Mar 25 14:43:25 EST 2006
Paul McGuire wrote:
> The alternatives I've come up with for the user to enable this packrat parse
> mode are:
>
> 1. Add a staticmethod enablePackrat() to the pyparsing ParserElement class,
> to modify the ParserElement defintion of the internal (non-packrat) parse()
> method. This method essentially runs code looking like:
>
> ParserElement.parse,ParserElement.originalParse = \
> ParserElement.packratParse,ParserElement.parse
Could you just define a module pyparsingpackrat like this:
from pyparsing import *
ParserElement.parse,ParserElement.originalParse = \
ParserElement.packratParse,ParserElement.parse
Then users would just import pyparsingpackrat instead of pyparsing.
Kent
More information about the Python-list
mailing list