<?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: Fix error in Python code in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317874#M24680</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;delete the" try" line and the last 3 lines&lt;/P&gt;&lt;P&gt;dedent the intermediate code by one level and run (ie. without the try-except block)&lt;/P&gt;&lt;P&gt;report any error messages that you have&lt;/P&gt;&lt;P&gt;If you aren't running a tool you can use print statements or "tweet" them to cover both scenarios&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;tweet&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""Produce a message for both arcpy and python
    : msg - a text message
    """&lt;/SPAN&gt;
    m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:07:05 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-12-11T15:07:05Z</dc:date>
    <item>
      <title>Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317866#M24672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P dir="ltr"&gt;I have &lt;STRONG&gt;Script&lt;/STRONG&gt; to create a tool, which converts a comma-delimited text file containing coordinates to a feature class within a database, but an &lt;STRONG&gt;unexpected error&lt;/STRONG&gt; appears as in the attached images, is there a workaround for that?&lt;BR /&gt;I used &lt;STRONG&gt;ArcMap 10.8&lt;/STRONG&gt;&amp;nbsp;to execute the code!&lt;/P&gt;&lt;P dir="ltr"&gt;&lt;STRONG&gt;Please Help...&lt;/STRONG&gt;&lt;/P&gt;&lt;P dir="ltr"&gt;&lt;STRONG&gt;&lt;IMG alt="Script" class="jive-emoji jive-image image-3 j-img-original" src="https://community.esri.com/legacyfs/online/502065_error1.png" /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P dir="ltr"&gt;&lt;IMG __jive_id="502064" alt="Error" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/502064_error2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2020 17:56:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317866#M24672</guid>
      <dc:creator>KhamisBaroud</dc:creator>
      <dc:date>2020-07-31T17:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317867#M24673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;get rid of the 'finally' section... in fact there is no reason for your code to be in a try-except block, you will get a useful error message without it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2020 20:17:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317867#M24673</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-07-31T20:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317868#M24674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In Python, the finally block of code is always executed regardless of what happens above with the try/except.&amp;nbsp; The problem you are running into is that you have defined a cursor with the try statement, but there is an exception happening before the cursor is defined.&amp;nbsp; Since the finally block always executes, it is trying to delete an object that doesn't exist, and hence you are seeing a NameError that isn't being caught by your try/except.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general, you should not be large blocks of code within try statements because it can obscure errors that you may want to pass along to the user.&amp;nbsp;&amp;nbsp; When using finally statements, don't have an object in them that is defined with the try statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2020 21:15:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317868#M24674</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-07-31T21:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317869#M24675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I deleted the " finally block", and the script ran without errors, but the result "Feature Class" doesn't show inside the program"ArcMap 10.8" or the location where saved it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Aug 2020 05:34:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317869#M24675</guid>
      <dc:creator>KhamisBaroud</dc:creator>
      <dc:date>2020-08-01T05:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317870#M24676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="border: 0px; font-weight: inherit; font-size: 14px;"&gt;&lt;DIV class="" style="border: 0px; font-weight: inherit; margin: 20px 0px;"&gt;&lt;P style="border: 0px; font-weight: inherit;"&gt;I deleted the &lt;STRONG&gt;" finally block"&lt;/STRONG&gt;, and the script ran without errors, but the result &lt;STRONG&gt;"Feature Class"&lt;/STRONG&gt; doesn't show inside the program&lt;STRONG&gt;"ArcMap 10.8"&lt;/STRONG&gt; or the location where saved it!!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV style="border: 0px; font-weight: inherit; font-size: 14px;"&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: inherit; font-size: 14px; margin: 20px 0px 0px;"&gt;&lt;DIV class="" data-comment-id="944904" style="color: #8b8b8b; border: none; font-weight: inherit; font-size: 0.8571rem;"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Aug 2020 05:37:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317870#M24676</guid>
      <dc:creator>KhamisBaroud</dc:creator>
      <dc:date>2020-08-01T05:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317871#M24677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did you get rid of the try-except block and keep del cur and f.close lines or did you keep the try-except and move them outside of the&amp;nbsp;try-except block?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Aug 2020 08:48:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317871#M24677</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-08-01T08:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317872#M24678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've deleted:&lt;BR /&gt;finally:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; del cur&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; f.close ()&lt;/P&gt;&lt;P&gt;........................................&lt;/P&gt;&lt;P&gt;The Script:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/502118_error3.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Aug 2020 10:31:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317872#M24678</guid>
      <dc:creator>KhamisBaroud</dc:creator>
      <dc:date>2020-08-01T10:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317873#M24679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's likely not being created and running your except block.&amp;nbsp; You can't see the error message because you're using a print statement in a script tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(arcpy.GetMessages())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would listen to what Dan is saying and get rid of your try/except block until things start working.&amp;nbsp; You shouldn't throw everything into a script tool straight away until you know the script works, it just makes debugging that much more difficult.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Aug 2020 12:28:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317873#M24679</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-08-01T12:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317874#M24680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;delete the" try" line and the last 3 lines&lt;/P&gt;&lt;P&gt;dedent the intermediate code by one level and run (ie. without the try-except block)&lt;/P&gt;&lt;P&gt;report any error messages that you have&lt;/P&gt;&lt;P&gt;If you aren't running a tool you can use print statements or "tweet" them to cover both scenarios&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;tweet&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""Produce a message for both arcpy and python
    : msg - a text message
    """&lt;/SPAN&gt;
    m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:07:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317874#M24680</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-11T15:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317875#M24681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Thank you for your response.&lt;/STRONG&gt;&lt;BR /&gt;The code is ready to go after the following fixes:&lt;BR /&gt;After checking the script again, I noticed two errors in writing the capital letters and an error in the position of the&amp;nbsp;index number, in addition to the last three lines where I deleted them.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The errors are apparent in the attached photo.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Error" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/502120_error5.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Aug 2020 21:37:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317875#M24681</guid>
      <dc:creator>KhamisBaroud</dc:creator>
      <dc:date>2020-08-01T21:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317876#M24682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am glad you got the code running, but your the try and finally blocks still run the risk of generating Python NameErrors that started this thread.&amp;nbsp; For example, if a user passes a bogus parameter, the exception will be caught but then the finally block will generate a NameError when it tries to delete the cursor that was never created in the first place. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Aug 2020 22:54:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317876#M24682</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-08-01T22:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317877#M24683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3420"&gt;Joshua Bixby&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;Can you explain more?&amp;nbsp;What should I do in order for the code to work properly?&lt;BR /&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2020 12:56:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317877#M24683</guid>
      <dc:creator>KhamisBaroud</dc:creator>
      <dc:date>2020-08-02T12:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317878#M24684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with an earlier comment by Dan, i.e., just get rid of the try/except/finally blocks altogether.&amp;nbsp; Looking at the code, your try/except/finally blocks aren't adding any value, i.e., you aren't handling any of the errors that could be generated.&amp;nbsp; Why trap an error if you aren't doing anything with it?&amp;nbsp; If you need, or think you need, a try statement; it is best to make them as narrow as possible.&amp;nbsp; Multiple function/method calls and loops, especially when combined, do not make for a narrow scope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As David points out above, the print statement doesn't do anything within a Script Tool since there is no console.&amp;nbsp; Your current code retrieves the messages from the last geoprocessing tool run (that is what GetMessages does), but the messages aren't returned to the user.&amp;nbsp; Additionally, no errors are returned to the user.&amp;nbsp; Do you really want the user to think the tool succeeded when it didn't?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Script tools pass errors back to the user by default, so you don't need to try to do it manually.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2020 17:02:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317878#M24684</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-08-02T17:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317879#M24685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although the &lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/insertcursor.htm"&gt;old InsertCursor &lt;/A&gt;still works with 10.8, you may wish to convert to the faster &lt;A _jive_internal="true" href="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/insertcursor-class.htm"&gt;da.InsertCursor&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Aug 2020 20:09:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317879#M24685</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2020-08-02T20:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317880#M24686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does the InsertCursor take a lock on the table? If so and the script fails in the for loop, is that lock returned?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2020 19:09:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317880#M24686</guid>
      <dc:creator>WillHouston</dc:creator>
      <dc:date>2020-08-03T19:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317881#M24687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;look at 'with'&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/1369526/what-is-the-python-keyword-with-used-for#:~:text=2%20Answers&amp;amp;text=In%20python%20the%20with%20keyword,even%20if%20exceptions%20are%20thrown."&gt;https://stackoverflow.com/questions/1369526/what-is-the-python-keyword-with-used-for#:~:text=2%20Answers&amp;amp;text=In%20python%20the%20with%20keyword,even%20if%20exceptions%20are%20thrown.&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2020 20:15:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317881#M24687</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-08-03T20:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317882#M24688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm aware of 'with', but the OP did not use 'with'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2020 20:19:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317882#M24688</guid>
      <dc:creator>WillHouston</dc:creator>
      <dc:date>2020-08-03T20:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Fix error in Python code</title>
      <link>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317883#M24689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When the script tool completes, whether successfully or with errors, all of the variables defined in the script (assuming no globals keyword is used) will go out of scope and the locks will go away.&amp;nbsp; Using Python 'with' reduces the chances of having problems if the script doesn't complete successfully, e.g., possibly not having the cursor fully flushed before terminating, but the locks will get removed whether cleanly or not. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2020 21:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fix-error-in-python-code/m-p/317883#M24689</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-08-03T21:53:02Z</dc:date>
    </item>
  </channel>
</rss>

