re.compile() doesn't work under Windows?

Carsten Haese carsten at uniqsys.com
Thu Aug 31 16:50:00 EDT 2006


On Thu, 2006-08-31 at 17:38, ddtl wrote:
> Hello everybody.
> 
> My script uses re.compile() function, and while it rans without errors
> under Linux, when I ran that script under Windows I get the following
> error:
> 
> Traceback (most recent call last):
>   File "C:\a\projects\re.py", line 4, in ?
>     import re
>   File "C:\a\projects\re.py", line 95, in ?
>     main()
>   File "C:\a\projects\re.py", line 37, in main
>     s_exp = re.compile(op['-s'])
> AttributeError: 'module' object has no attribute 'compile'
> 
> What is the problem here? re module is installed and is on the path - 
> for example, the following code works and doesn't cause any errors:
> 
> import re
> re.compile('a')
> 
> What else could cause such an error?

Your script is called re, so "import re" is making the script import
itself instead of the re module from the library.

-Carsten





More information about the Python-list mailing list