<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python script question in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551489#M89432</link>
    <description>&lt;P&gt;UseThis = 2&lt;BR /&gt;##&lt;BR /&gt;arcpy.SelectLayerByLocation_management("BIRDLINE_LAYER", "intersect", "BigPoly", 0, "new_selection")&lt;BR /&gt;arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', '"Route" = 2')&lt;BR /&gt;#arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', '"Route" = UseThis')&lt;BR /&gt;#arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', "UseThis" )&lt;/P&gt;&lt;P&gt;Only the first&amp;nbsp;'SUBSET_SELECTION', works.&amp;nbsp; &amp;nbsp;How can I use the value of 'UseThis' ??&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2024 18:27:37 GMT</pubDate>
    <dc:creator>JRR</dc:creator>
    <dc:date>2024-10-23T18:27:37Z</dc:date>
    <item>
      <title>Python script question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551489#M89432</link>
      <description>&lt;P&gt;UseThis = 2&lt;BR /&gt;##&lt;BR /&gt;arcpy.SelectLayerByLocation_management("BIRDLINE_LAYER", "intersect", "BigPoly", 0, "new_selection")&lt;BR /&gt;arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', '"Route" = 2')&lt;BR /&gt;#arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', '"Route" = UseThis')&lt;BR /&gt;#arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', "UseThis" )&lt;/P&gt;&lt;P&gt;Only the first&amp;nbsp;'SUBSET_SELECTION', works.&amp;nbsp; &amp;nbsp;How can I use the value of 'UseThis' ??&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 18:27:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551489#M89432</guid>
      <dc:creator>JRR</dc:creator>
      <dc:date>2024-10-23T18:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python script question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551532#M89433</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/507303"&gt;@JRR&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you need to pass the input as a function string:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;UseThis = 2
arcpy.SelectLayerByLocation_management("BIRDLINE_LAYER", "intersect", "BigPoly", 0, "new_selection")
arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', '"Route" = 2')
arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', f'"Route" = {UseThis}')&lt;/LI-CODE&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 19:09:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551532#M89433</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-10-23T19:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python script question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551570#M89435</link>
      <description>&lt;P&gt;That seems to only apply to rasters.&amp;nbsp; Thanks for your response!&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', f'"Route" = {UseThis}')&lt;/P&gt;&lt;P&gt;show invalid expression&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 19:36:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551570#M89435</guid>
      <dc:creator>JRR</dc:creator>
      <dc:date>2024-10-23T19:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Python script question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551585#M89436</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/507303"&gt;@JRR&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ah alright I see, it may be because your Route attribute is expected to be a certain data type, if it's an integer it would be something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', f'"Route" = {UseThis}')&lt;/LI-CODE&gt;&lt;P&gt;Otherwise, if it is a string, it should be this here:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', f'"Route" = \'{UseThis}\'')&lt;/LI-CODE&gt;&lt;P&gt;This escapes the single quotes to be used in the SQL. Hopefully this solves it for you!&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 19:57:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1551585#M89436</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-10-23T19:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python script question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1552115#M89482</link>
      <description>&lt;P&gt;Neither of these lines work.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JRR_0-1729804855506.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/118083iCF817EEF378CC995/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JRR_0-1729804855506.png" alt="JRR_0-1729804855506.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 21:21:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1552115#M89482</guid>
      <dc:creator>JRR</dc:creator>
      <dc:date>2024-10-24T21:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python script question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1552330#M89501</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/507303"&gt;@JRR&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The errors are not very descriptive using IDLE, you may have better luck and better error reporting when using Visual Studio Code instead.&lt;/P&gt;&lt;P&gt;Give this a shot here, this builds the query outside of the function:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;UseThis = 2

arcpy.SelectLayerByLocation_management("BIRDLINE_LAYER", "intersect", "BigPoly", 0, "new_selection")

sql_expression = f'"Route" = {UseThis}'

print(sql_expression) # Just use this to test to see if it's actually printing anything and that the expression looks correct

arcpy.SelectLayerByAttribute_management('BIRDLINE_LAYER', 'SUBSET_SELECTION', sql_expression)&lt;/LI-CODE&gt;&lt;P&gt;I would ensure that the print statement is in there for debugging.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 13:37:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1552330#M89501</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-10-25T13:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python script question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1554806#M89724</link>
      <description>&lt;P&gt;I tried with no success.&amp;nbsp; &amp;nbsp;Sorry to be so late in responding.. traveling.&lt;/P&gt;&lt;P&gt;Sent the code and a sample data set.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 18:28:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-question/m-p/1554806#M89724</guid>
      <dc:creator>JRR</dc:creator>
      <dc:date>2024-11-01T18:28:17Z</dc:date>
    </item>
  </channel>
</rss>

