Seems like I've had this problem before, but I can't find the solution searching in my past posts.
I need to step through a list of alpha site-ids, and make a selection to a table view based on the given value of the list element. Something like this:
my_list <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'BC_00.1'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'BC_00.2'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'BC_00.3'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> my_list<SPAN class="punctuation token">:</SPAN>
select <SPAN class="operator token">=</SPAN> <SPAN class="string token">'SITE_ID = {}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">### <--- problem child</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>tableview<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"NEW_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN>select<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>but my select variable is set up wrong in line 4 so I get barked at that line 5 has a syntax error. It's question of where single and double quotes go in line 4, and for the life of me I just can't seem to get it. (Could it be the last 10 days in the Mexican Riviera? Forgetting code snippets is the new Montezuma's Revenge. I once forgot my zip code after a trip to Mexico; that was great vacation...)