Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying pass year variable to re.findall, but it doesn't work(no errors). Can anyone specify where I'm going wrong?

year=2013
links = re.findall(r"('+year+'-.*\/t.*.html)", line)

share|improve this question
    
What is r here? –  i08in Oct 3 '13 at 5:47
    
r ---> Raw string –  Kummi_10 Oct 3 '13 at 5:49
add comment

1 Answer 1

up vote 1 down vote accepted

year should be out of the quotes, since it is a variable:

year = 2013
links = re.findall(r + '(' + str(year) + '-.*\/t.*.html)', line)
share|improve this answer
    
r is not a variable but denotes raw string. This should probably be: r'(' + str(year) + r'-.*... –  Javier Rivera Oct 4 '13 at 6:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.