<?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: How to delete a Search Cursor that is never named in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299909#M23224</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the point layer is still there, there is no cursor and the point layer is closed by the with statement.&lt;/P&gt;&lt;P&gt;Experiment with a large file, one that would take a second or two to process and monitor memory usage.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Apr 2018 22:17:55 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-04-02T22:17:55Z</dc:date>
    <item>
      <title>How to delete a Search Cursor that is never named</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299905#M23220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just want a record count from a Search Cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I write a line like this&lt;/P&gt;&lt;P&gt;nom = len(list(arcpy.da.SearchCursor(pointLayer, fields, whereClause)))&lt;/P&gt;&lt;P&gt;do I have to worry about deleting the cursor for cleanup?&amp;nbsp; And if so how?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or is something like this safer?&lt;/P&gt;&lt;P&gt;with arcpy.da.SearchCursor(pointLayer, fields, whereClause) as cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; denom = len(list(cursor))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or if I stick the cursor in a function will it release it when the function is done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2018 20:05:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299905#M23220</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2018-04-02T20:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete a Search Cursor that is never named</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299906#M23221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;with is usually good since it ensures that things get closed properly when done or things go wrong&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.python.org/3/reference/compound_stmts.html#the-with-statement"&gt;https://docs.python.org/3/reference/compound_stmts.html#the-with-statement&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.python.org/3/reference/datamodel.html#context-managers"&gt;https://docs.python.org/3/reference/datamodel.html#context-managers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As a little test, run your code snippet in your python IDE, then see if cursor still exists&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;locals().keys()&amp;nbsp; # is it there?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2018 20:26:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299906#M23221</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-04-02T20:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete a Search Cursor that is never named</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299907#M23222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get this&lt;/P&gt;&lt;P&gt;['nom', 'pointLayer', 'surveyGeo', 'whereClause', '__builtins__', 'fields', '__file__', '__package__', 'sys', 'arcgis', 'time', '__name__', 'datetime', 'arcpy', '__doc__', 'math']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But with no name what am I looking for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2018 20:31:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299907#M23222</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2018-04-02T20:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete a Search Cursor that is never named</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299908#M23223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If there are no references to the object, garbage collection will eventually take care of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding counting records, there have been numerous discussions over the years on Esri forums, GeoNet, StackExchange, etc... about what are the "best" and "fastest" ways:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/thread/90485"&gt;How to determine number of records using arcpy.da.SearchCursor&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/thread/115755"&gt;Fastest way to get number of rows in a da.SearchCursor&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A class="link-titled" href="https://gis.stackexchange.com/questions/30140/fastest-way-to-count-the-number-of-features-in-a-feature-class" title="https://gis.stackexchange.com/questions/30140/fastest-way-to-count-the-number-of-features-in-a-feature-class"&gt;arcgis desktop - Fastest way to count the number of features in a feature class? - Geographic Information Systems Stack …&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should look into using&lt;CODE&gt; &lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/get-count.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/get-count.htm"&gt;Get Count—Data Management toolbox | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2018 20:58:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299908#M23223</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-04-02T20:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete a Search Cursor that is never named</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299909#M23224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the point layer is still there, there is no cursor and the point layer is closed by the with statement.&lt;/P&gt;&lt;P&gt;Experiment with a large file, one that would take a second or two to process and monitor memory usage.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2018 22:17:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-a-search-cursor-that-is-never-named/m-p/299909#M23224</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-04-02T22:17:55Z</dc:date>
    </item>
  </channel>
</rss>

