Custom behavior defined in the imported module

Paul McGuire ptmcg at austin.rr._bogus_.com
Sat Mar 25 20:54:22 CET 2006


"Kent Johnson" <kent at kentsjohnson.com> wrote in message
news:44259839$1_2 at newspeer2.tds.net...
> 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

I *really* like keeping pyparsing's footprint down





More information about the Python-list mailing list