Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module 're' has no attribute 'findall' [duplicate]

Tags:

python

regex

I am trying to use the following python module:

import re
test = 'some text'
find = re.findall(r'text', test)
print(find)

When i try to run it in sublime, it writes:

AttributeError: module 're' has no attribute 'findall'

If i try to run it in Cygwin, there is a message:

AttributeError: 'module' object has no attribute 'findall'

But if i use attibute "findall" in python console, it works without any problem. I really don't undestand, what's wrong. In Sublime i use python 3.5.1, cygwin uses python 3.4.3, as i remember.

like image 965
mrser Avatar asked Mar 11 '16 20:03

mrser


1 Answers

If you have a file called re.py, then when you try and import re, Python may look inside that file instead of inside the standard module re. So don't name a file re.py (or the name of any other module you want to import).

like image 163
khelwood Avatar answered Oct 26 '22 19:10

khelwood