d@home$ cat re.py import re re_string = "{{(.*?)}}" some_string = "this is a string with {{words}} embedded in {{curly brackets}} to show an {{example}} of {{regular expression}}" for match in re.findall(re_string,some_string): print 'Match->', match
ERROR:
Traceback (most recent call last): File "re.py", line 1, in <module> import re File "/home/nikid/PythonSysadmin/re.py", line 4, in <module> for match in re.findall(re_string,some_string): AttributeError: 'module' object has no attribute 'findall' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 48, in apport_excepthook if not enabled(): File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 21, in enabled import re File "/home/nikid/PythonSysadmin/re.py", line 4, in <module> for match in re.findall(re_string,some_string): AttributeError: 'module' object has no attribute 'findall' Original exception was: Traceback (most recent call last): File "re.py", line 1, in <module> import re File "/home/nikid/PythonSysadmin/re.py", line 4, in <module> for match in re.findall(re_string,some_string): AttributeError: 'module' object has no attribute 'findall'
Solution:
rename the file re.py to another name
Another one
ERROR:
NameError: name 'randint' is not defined
Solution:
Rename the random.py to different name..
REFERENCES
http://www.willmer.com/kb/2007/12/attributeerror-module-object-has-no-attribute-blah/