I am working on a simple application. The user can choose either Numeric values or string values to select (i.e. valName). However if you write the where clause like this:
arcpy<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SelectLayerByAttribute_management</SPAN><SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NEW_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN> FieldName <SPAN class="operator token">+</SPAN> opName <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN> <SPAN class="operator token">+</SPAN> valName <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
It doesn't work for numbers and if you write like this:
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NEW_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN>FieldName <SPAN class="operator token">+</SPAN> opName <SPAN class="operator token">+</SPAN> valName<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
It doesn't work for strings.
Any simple solution without if condition?