<?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: local variable 'row' referenced before assignment				 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655356#M51033</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi rebecca thank you very much,&lt;/P&gt;&lt;P&gt;but why del don't work here. Iuse it to clean the processus of running code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Jan 2016 21:35:41 GMT</pubDate>
    <dc:creator>ben_abdallahmhd</dc:creator>
    <dc:date>2016-01-09T21:35:41Z</dc:date>
    <item>
      <title>local variable 'row' referenced before assignment</title>
      <link>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655354#M51031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;when i run this code the message&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;"local variable 'row' referenced before assignment"&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; appear but i think the name o the &lt;/P&gt;&lt;P&gt;variable and the indentation are correct.&lt;/P&gt;&lt;P&gt; tb = table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if tb is "RRAXERCL":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldsToConcat_RRAXERCL = ["CODECAVA","CODCLASS","TYPERTCR","PROFILRC","ETATRTCR"]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursorup = arcpy.da.UpdateCursor(table,fieldsToConcat_RRAXERCL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursorup :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; row&lt;/STRONG&gt;[0] = str(row[1]) + str(row[2]).rjust(2,'0') + str(row[3]).rjust(2,'0') + str(row[4]).rjust(2,'0') + str('00')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursorup.updateRow(row)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;del row&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cursorup&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jan 2016 20:13:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655354#M51031</guid>
      <dc:creator>ben_abdallahmhd</dc:creator>
      <dc:date>2016-01-09T20:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: local variable 'row' referenced before assignment</title>
      <link>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655355#M51032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a guess, since it is not formatted&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (see &lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;​)&amp;nbsp; But my guess is that the&lt;/P&gt;&lt;P&gt;del row&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is what is causing the issue. ....&lt;/P&gt;&lt;P&gt;edit...mayeb becaue it is not returning anything for cursorup....or more likely, I don't think you even need to delete the row&amp;nbsp;&amp;nbsp; with .da&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And depending on what ArcGIS version you are using, you may want to review &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/python/data-access-using-cursors.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/python/data-access-using-cursors.htm"&gt;Accessing data using cursors—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp; for your cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jan 2016 20:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655355#M51032</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-01-09T20:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: local variable 'row' referenced before assignment</title>
      <link>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655356#M51033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi rebecca thank you very much,&lt;/P&gt;&lt;P&gt;but why del don't work here. Iuse it to clean the processus of running code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jan 2016 21:35:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655356#M51033</guid>
      <dc:creator>ben_abdallahmhd</dc:creator>
      <dc:date>2016-01-09T21:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: local variable 'row' referenced before assignment</title>
      <link>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655357#M51034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is some info regarding locks in the help doc I included above....a snippet from it is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P style="font-size: 0.875rem; margin-bottom: 1.71429em; color: #4d4d4d; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif;"&gt;In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Including the cursor inside a &lt;SPAN class="usertext" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-weight: bold;"&gt;with&lt;/SPAN&gt; statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed&lt;/LI&gt;&lt;LI&gt;Calling &lt;SPAN class="usertext" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-weight: bold;"&gt;reset()&lt;/SPAN&gt; on the cursor&lt;/LI&gt;&lt;LI&gt;The completion of the cursor&lt;/LI&gt;&lt;LI&gt;Explicitly deleting the cursor using Python's &lt;SPAN class="usertext" style="font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-weight: bold;"&gt;del&lt;/SPAN&gt; statement&lt;/LI&gt;&lt;/UL&gt;&lt;P style="font-size: 0.875rem; margin-bottom: 1.71429em; color: #4d4d4d; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif;"&gt;An edit session in ArcMap applies a shared lock to data during the edit session. An exclusive lock is applied when edits are saved. A dataset is not editable if an exclusive lock already exists.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P style="font-size: 0.875rem; margin-bottom: 1.71429em; color: #4d4d4d; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif;"&gt;Using the first type, the "with" statement, tends to be the preferred method I've seen in the forums.&amp;nbsp; There are some good examples showing this on that same help document.&amp;nbsp; I hope that helps explain "why".&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jan 2016 22:31:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/local-variable-row-referenced-before-assignment/m-p/655357#M51034</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-01-09T22:31:18Z</dc:date>
    </item>
  </channel>
</rss>

