Strange re problem on OSX but Not Linux

B

Brian

I have a very small script:

import re

text = open('eq.txt','r').read()
regex = '[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]'
pattern = re.compile(regex)
match = pattern.findall(text)

print ''.join(match)

However, when I try to run it, I get this error:

Traceback (most recent call last):
File
"/Applications/Komodo.app/Contents/SharedSupport/dbgp/bin/pydbgp", line
66, in <module>
import dbgp.client
File
"/Applications/Komodo.app/Contents/SharedSupport/dbgp/pythonlib/dbgp/client.py",
line 44, in <module>
import traceback, re
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 5, in <module>
#
AttributeError: 'module' object has no attribute 'compile'

-------------------------------------------------------------------------------
Here is the error outside of Komodo:

Traceback (most recent call last):
File "reg1.py", line 1, in <module>
import re
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 5, in <module>
#
AttributeError: 'module' object has no attribute 'compile'
------------------------------------------------------------------------------

This is running 2.5 on my OSX box. If I run it (again with 2.5) on my
SUSE machine, I get no errors.

I am sure that I have overlooked something trivial here - so please be
gentle if it is on the stupid side of things.

Thanks,
Brian
 
G

Gabriel Genellina

I have a very small script:

import re

text = open('eq.txt','r').read()
regex = '[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]'
pattern = re.compile(regex)
match = pattern.findall(text)

print ''.join(match)

-------------------------------------------------------------------------------
Here is the error outside of Komodo:

Traceback (most recent call last):
File "reg1.py", line 1, in <module>
import re
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 5, in <module>
#
AttributeError: 'module' object has no attribute 'compile'
------------------------------------------------------------------------------

This is running 2.5 on my OSX box. If I run it (again with 2.5) on my
SUSE machine, I get no errors.

I am sure that I have overlooked something trivial here - so please be
gentle if it is on the stupid side of things.

Dont use regex as a name. Also, do you have any script called "re.py"
hidding that library module? or regex.py?


--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
 
P

Paul McGuire

Gabriel Genellina said:
Dont use regex as a name. Also, do you have any script called "re.py"
hidding that library module? or regex.py?

My bet is that a local re.py is masking the lib module. (It's a shame this
error is so easy to trip over.)

-- Paul
 
B

Brian

Paul said:
My bet is that a local re.py is masking the lib module. (It's a shame this
error is so easy to trip over.)

-- Paul

I figured that one out so I renamed the file. Unfortunately it took me
a while to realize that I needed to delete re.pyc as well.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top