regexp help

Paul McGuire ptmcg at austin.rr.com
Sat May 10 00:04:16 EDT 2008


On May 9, 6:52 pm, John Machin <sjmac... at lexicon.net> wrote:
> Paul McGuire wrote:
> > from re import *
>
> Perhaps you intended "import re".

Indeed I did.

> <snip>
>
> > Both print "prince".
>
> No they don't. The result is "NameError: name 're' is not defined".

Dang, now how did that work in my script?  I assure you I did test it
before posting.

Ah!  My pyparsing prototype preceded the regex version in the same
script, and importing the pyparsing module imports re using "import
re".  That is why I didn't get NameError.  Sorry for sloppy posting...

Once you clean up the mistakes, you essentially get the same code as
earlier posted by Matimus.

-- Paul



More information about the Python-list mailing list