I'm writing a program with python that compiles a list of decorators from my company's source code. I'm new to python and need help with the following:<div>I'm trying to make the program find ".com" in any lines and not include them in the list of decorators that gets returned. THis is because I had the program look for the @ symbol to find the decorators and it returned email addresses in the list. What I was thinking was to do something like this:</div>
<div>k = candidate_line.find(".com")</div><div>if k != -1:</div><div> candidate_line != candidate_line</div><div><br></div><div>The problem is that I know this won't work because ".com" can't be in the last slot of the candidate line... So far the part of my code that needs to be changed looks like this...</div>
<div><br></div><div><br></div><div><div><div> #parse out the names of the decorators from those lines</div><div> return_decorators= []</div><div> for ele in subset_lines:</div><div> candidate_line, line_number = ele</div>
<div> candidate_line = candidate_line.strip()</div><div> i = candidate_line.find("(")</div><div> j = candidate_line.find("#")</div><div> <span class="Apple-style-span" style="background-color: rgb(255, 255, 102);"> k = candidate_line.find(".com")</span></div>
<div> #if () is in the last spot</div><div> if i == -1:</div><div> #if () is in the last spot and the decorator is in a comment</div><div> if j == 0:</div>
<div> #get rid of ( and #</div><div> candidate_line = candidate_line[2:i]</div><div> #if () is in the last spot and the decorator is not in a comment </div>
<div> elif j != 0:</div><div> candidate_line = candidate_line[1:i]</div><div> #if there are not ()'s in the last spot</div><div> elif i != -1:</div>
<div> #if there are not ()'s, but the decorator is in a comment</div><div> if j == 0:</div><div> candidate_line = candidate_line[2:]</div><div>
#if there are not ()'s and the decorator isn't in a comment</div><div> elif j != 0:</div><div> candidate_line = candidate_line[1:]</div>
<div><span class="Apple-style-span" style="background-color: rgb(255, 255, 102);"> elif k in candidate_line:</span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 102);"> candidate_line != candidate_line</span></div>
</div></div>