2.1.1 and regexp

Dave Pawson DaveP at dpawson.freeserve.co.uk
Tue Dec 4 13:02:48 EST 2001


"Fredrik Lundh" <fredrik at pythonware.com> wrote in news:iX_O7.765$l93.304398
@newsb.telia.net:

> Dave Pawson wrote:
>> Now I'm even more confused :-)

> do you get this deep inside the 4suite code, or is this
> in your own code?
> 
> does it say:
> 
>     AttributeError: 're' module has no attribute 'compile'
> 
> or
> 
>     AttributeError: some object has no attribute 'compile'
> 
> if the latter, "re" is probably not what you think:
indeedy. I fell for what must be a real newbie trap.

> 
>     import re
> 
>     # compile some regexps
>     re = re.compile("...")
>     re2 = re.compile("...") # oops
> 
> if the former, maybe you have your own "re" (or "sre") script
> or module somewhere in the path?

Huge chuckles. I had re.py (stop laughing :-)


> 
> adding a "print re" or even "print re.__file__" to the line before
> the one that gives you the error might provide additional clues.
> 
> running the interpreter with the -v option might also help.
> 
> hope this helps!

Luckily I found it on my own (less embarassment?)

Hint to other newbies, don't name your files after
module names, or be prepared to blush!

Three installs of python and some help from Uche at 4suite solved it for me.

Thanks Fredrik, I'll creep into a corner.
Still grinning at the power of py though!!!

Regards DaveP



More information about the Python-list mailing list