title: Assign variable name to list in if statement python
body: <p>I apologize for the poor title. Wasn't sure exactly how to word my question.
  I have code below which uses a list of tuples called <code>propadd</code>. The <code>if statement</code> tests the tuples for matching conditions. If the match matches to only 1 tuple from the list of tuples, it executes the exact same code as that in the if statement so as to assign this matching tuple to variable v in order to update the cursor rows with values from this matching tuple. I would like to know if there's a way to get rid of the assignment of the exact same code to v after the if statement. Is it possible to assign the list to v in the if statement while checking for the length of the matches? This is part of a larger amount of code that follows this methodology. I believe that doing this will make my code faster.</p>
  
  <pre><code>if len([item for item in propadd if item[0]==row1[8] and harversine(custx,custy,item[2],item[3])&lt;1500]) == 1:
          v=[item for item in propadd if item[0]==row1[8] and harversine(custx,custy,item[2],item[3])&lt;1500]
          row1[1]=v[0][1]
          row1[2]=v[0][2]
  elif len([item for item in custadd if item[0]==row1[4]]) == 1:
          k=[item for item in custadd if item[0]==row1[4]]
          row1[1]=k[0][1]
          row1[2]=k[0][2]
  elif len([item for item in numlist if re.search(r"^[0-9]+(?=\s)",row1[0]) is not None and item[0]==re.search(r"^[0-9]+(?=\s)",row1[0]).group()]) == 1
          m=[item for item in numlist if re.search(r"^[0-9]+(?=\s)",row1[0]) is not None and item[0]==re.search(r"^[0-9]+(?=\s)",row1[0]).group()]
          row1[1]=m[0][1]
          row1[2]=m[0][2]
  </code></pre>