NameError: name 're' is not defined
Question: I am very new to python. Very new. I copied the following from a tutorial

    
    
    #!/usr/bin/python
    import re
    from urllib import urlopen
    from BeautifulSoup import BeautifulSoup
    
    webpage = urlopen('http://feeds.huffingtonpost.com/huffingtonpost/LatestNews').read
    
    patFinderTitle = re.compile('<title>(.*)</title>')
    
    patFinderLink = re.compile('<link rel.*href="(.*)"/>')
    
    findPatTitle = re.findall(patFinderTitle,webpage)
    
    findPatLink = re.findall(patFinderLink,webpage)
    
    listIterator = []
    listIterator[:] = range(2,16)
    
    for i in listIterator:
        print findPatTitle[i]
        print findPatLink[i]
        print "\n"
    

I get the error:

    
    
    Traceback (most recent call last):
      File "test.py", line 8, in <module>
        patFinderTitle = re.compile('<title>(.*)</title>')
    NameError: name 're' is not defined
    

What am I doing wrong?

Edit: I added `import re` but now get the following:

    
    
    File "/scripts/_prod/test.py", line 13, in <module>
        findPatTitle = re.findall(patFinderTitle,webpage)
      File "/usr/lib64/python2.6/re.py", line 177, in findall
        return _compile(pattern, flags).findall(string)
    TypeError: expected string or buffer
    


Answer: You need to import [regular expression
module](http://docs.python.org/library/re.html) in your code

    
    
    import re
    re.compile('<title>(.*)</title>')
    

