Custom behavior defined in the imported module

Paul McGuire ptmcg at austin.rr._bogus_.com
Sat Mar 25 14:56:17 EST 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
(damned touchy touchpad!)

... anyway...

I *really* like keeping pyparsing's footprint down to just one Python
module.  It would be nice if I could pass an argument along with the import
statement:

import pyparsing(packrat=True)

or some such.

-- Paul





More information about the Python-list mailing list