<?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 Re: Search Cursor Structure in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134631#M10556</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When using arcpy.da.SearchCursor() each row is returned as list of values, correct call to get attribute value for row would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause)&amp;nbsp; df.extent = lyr.getSelectedExtent()&amp;nbsp; df.scale = df.scale*1.1&amp;nbsp; arcpy.AddMessage(str(whereClause))&amp;nbsp;&amp;nbsp; cursor = arcpy.da.SearchCursor("Land", ["ValueGain"])&amp;nbsp; for row in cursor: &amp;nbsp; arcpy.AddMessage(str(row[0])) # row[0] = first element of list that represents row&amp;nbsp; del row&amp;nbsp; del cursor&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In case from your code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.AddMessage(str(ValueGain))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;ValueGain is unassigned variable, so you will get error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Aug 2013 13:39:59 GMT</pubDate>
    <dc:creator>ArkadiuszMatoszka</dc:creator>
    <dc:date>2013-08-07T13:39:59Z</dc:date>
    <item>
      <title>Search Cursor Structure</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134630#M10555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using a SearchCursor to return a value from a selected attribute field.&amp;nbsp; But, the cursor does not work or create an error.&amp;nbsp; The ValueGain filed is a Long field type that is has not been set to a string.&amp;nbsp; I am only using the SearchCursor to return a value in the tool dialog window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause) df.extent = lyr.getSelectedExtent() df.scale = df.scale*1.1 arcpy.AddMessage(str(whereClause))&amp;nbsp; cursor = arcpy.da.SearchCursor("Land", ["ValueGain"]) for row in cursor:&amp;nbsp; arcpy.AddMessage(str(ValueGain))&amp;nbsp; del row&amp;nbsp; del cursor&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 13:29:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134630#M10555</guid>
      <dc:creator>JamesSmith7</dc:creator>
      <dc:date>2013-08-07T13:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Search Cursor Structure</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134631#M10556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When using arcpy.da.SearchCursor() each row is returned as list of values, correct call to get attribute value for row would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause)&amp;nbsp; df.extent = lyr.getSelectedExtent()&amp;nbsp; df.scale = df.scale*1.1&amp;nbsp; arcpy.AddMessage(str(whereClause))&amp;nbsp;&amp;nbsp; cursor = arcpy.da.SearchCursor("Land", ["ValueGain"])&amp;nbsp; for row in cursor: &amp;nbsp; arcpy.AddMessage(str(row[0])) # row[0] = first element of list that represents row&amp;nbsp; del row&amp;nbsp; del cursor&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In case from your code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.AddMessage(str(ValueGain))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;ValueGain is unassigned variable, so you will get error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 13:39:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134631#M10556</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2013-08-07T13:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Search Cursor Structure</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134632#M10557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the quick response.&amp;nbsp; Your suggestion worked.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 13:43:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134632#M10557</guid>
      <dc:creator>JamesSmith7</dc:creator>
      <dc:date>2013-08-07T13:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Search Cursor Structure</title>
      <link>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134633#M10558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;each row is returned as list of values&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To be more precise, each row is returned as a Python tuple... which is similar to a Python list, but one that can't be rearanged/sorted (aka an imutable list).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Python:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;tupleExample = (1,2,3,4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;listExample = [1,2,3,4]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 15:17:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-cursor-structure/m-p/134633#M10558</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-08-07T15:17:26Z</dc:date>
    </item>
  </channel>
</rss>

