<?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: Python Script just stopped working..totally stumped in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-just-stopped-working-totally-stumped/m-p/259013#M19927</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Caleb, thanks that is exactly what the problem was. I should have caught that earlier but I think I was looking to deep and overlooked the obvious. Thanks again for the explanation!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Apr 2013 13:58:19 GMT</pubDate>
    <dc:creator>JohnCarr2</dc:creator>
    <dc:date>2013-04-18T13:58:19Z</dc:date>
    <item>
      <title>Python Script just stopped working..totally stumped</title>
      <link>https://community.esri.com/t5/python-questions/python-script-just-stopped-working-totally-stumped/m-p/259011#M19925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey everyone, I have a simple script pasted below that searches through a field containing numbers (the field is type double) in a feature class and returns what would be the next highest unused number in the field. I ran this script probably 20 times yesterday and it worked fine, then all the sudden it stopped working and I started getting this error...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 10, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NameError: name 'AccessDBNo' is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas? I've never had something work and then suddenly not work with no changes made to the script whatsoever. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = r"Database Connections\PTWP_Base.sde\PTWP_BASE.DBO.Propose_Facilities"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc = "PTWP_BASE.DBO.Eval_Seg"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;numbers = []&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor(fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in rows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; numbers.append(row.getValue(AccessDBNo))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;numbers.sort()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;max = numbers[-1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NextNo=max+1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("The next available project number is...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage(NextNo)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Apr 2013 12:44:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-just-stopped-working-totally-stumped/m-p/259011#M19925</guid>
      <dc:creator>JohnCarr2</dc:creator>
      <dc:date>2013-04-18T12:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script just stopped working..totally stumped</title>
      <link>https://community.esri.com/t5/python-questions/python-script-just-stopped-working-totally-stumped/m-p/259012#M19926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think you were getting that error because your field AccessDBNo was referenced like a variable rather than a string for the field.&amp;nbsp; This would not be a problem had you actually created the variable before passing it into the getValue().&amp;nbsp; If you use the row.getValue() you have to have the field name inside the parenthesis as a string or you can use a variable to represent the string name of the field.&amp;nbsp; So you would do it like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# hard coded row.getValue("AccessDBNo")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;OR&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# uses variable field = "AccessDBNo" rows = arcpy.SearchCursor(fc) for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; numbers.append(row.getValue(field)) del row, rows &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The getValue method is most useful when the field is stored as a variable so you do not have to hard code the field name in.&amp;nbsp; Alternatively you can use this method to get the value:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;row.AccessDBNo&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that was the problem in your code.&amp;nbsp; I have made a few changes to your original code to use the built in max() function.&amp;nbsp; I also renamed your "max" variable because this is a reserved word for the max() function.&amp;nbsp; As to why it worked 20 times then randomly stopped, I do not know why that would happen.&amp;nbsp; Hopefully this works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import env env.workspace = r"Database Connections\PTWP_Base.sde\PTWP_BASE.DBO.Propose_Facilities" fc = "PTWP_BASE.DBO.Eval_Seg"&amp;nbsp; numbers = [] rows = arcpy.SearchCursor(fc) for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; numbers.append(row.AccessDBNo) del row, rows&amp;nbsp; # Get maximum using max() function, max is a reserved word for max() function.&amp;nbsp;&amp;nbsp; maxi = max(numbers)&amp;nbsp; NextNo = maxi + 1&amp;nbsp; arcpy.AddMessage("The next available project number is...") arcpy.AddMessage(NextNo) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Apr 2013 13:29:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-just-stopped-working-totally-stumped/m-p/259012#M19926</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-04-18T13:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script just stopped working..totally stumped</title>
      <link>https://community.esri.com/t5/python-questions/python-script-just-stopped-working-totally-stumped/m-p/259013#M19927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Caleb, thanks that is exactly what the problem was. I should have caught that earlier but I think I was looking to deep and overlooked the obvious. Thanks again for the explanation!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Apr 2013 13:58:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-just-stopped-working-totally-stumped/m-p/259013#M19927</guid>
      <dc:creator>JohnCarr2</dc:creator>
      <dc:date>2013-04-18T13:58:19Z</dc:date>
    </item>
  </channel>
</rss>

