<?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: error creating list with append in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-creating-list-with-append/m-p/155307#M11987</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you run a script outside of Arc*, it knows nothing about your working environment, you need to specify your working folder where your layers are located using arcpy.env = .....&lt;/P&gt;&lt;P&gt;I don't know if it matters, but your list isn't...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;layerList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"zoning"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"fldplain"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"compplan"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"fire"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"school"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"irrigate"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ressoils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"soils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"uga"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layerList&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Out&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; set&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And cycling through a set can cause some issues... like the order is out of whack&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; layerList&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;i&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
irrigate
compplan
uga
ressoils
fldplain
school
soils
fire
zoning&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;/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 08:15:38 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-11T08:15:38Z</dc:date>
    <item>
      <title>error creating list with append</title>
      <link>https://community.esri.com/t5/python-questions/error-creating-list-with-append/m-p/155306#M11986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This should be so easy. &amp;nbsp;I have a script that runs perfectly from the ArcMap python window, but errors out when run from a script tool or IDLE. &amp;nbsp;It errors on the AddJoin because it says that finalParc does not exist. &amp;nbsp;I believe it is because the Intersect_analysis is not running correctly. &amp;nbsp;I don't know if the inFeatures list is not being created correctly or it is having trouble with the names in the list. &amp;nbsp;The point of my script is to determine if the main layer - parcBuff - is overlapped by any of the other layers. &amp;nbsp;If it is, then run an intersect_analysis on those overlapping layers to create one final layer - finalParc - that has the attributes of all those layers in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is part of the code that should accomplish that...and I need it to run through a Tool.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create a cursor to go through all the layers. If layer does not intersect, apply N/A, otherwise, intersect....&lt;BR /&gt;#Make Layer Views......&lt;BR /&gt;arcpy.MakeFeatureLayer_management(parcBuff, "parcBuff")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(zoning, "zoning")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(fldplain, "fldplain")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(compplan, "compplan")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(fire, "fire")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(school, "school")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(irrigate, "irrigate")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(ressoils, "ressoils")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(soils, "soils")&lt;BR /&gt;arcpy.MakeFeatureLayer_management(uga, "uga")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#Cursor layers......&lt;BR /&gt;layerList = {"zoning", "fldplain", "compplan", "fire", "school", "irrigate", "ressoils", "soils", "uga"}&lt;BR /&gt;inFeatures = ["parcBuff"]&lt;BR /&gt;for theLayer in layerList:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;arcpy.SelectLayerByLocation_management("parcBuff", "INTERSECT", theLayer)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;selCount = int(arcpy.GetCount_management("parcBuff").getOutput(0))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;print selCount&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (selCount != 0):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;inFeatures.append("%s" % theLayer)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#inFeatures = ["parcBuff", "zoning", "fldplain", "compplan", "uga", "soils", "ressoils", "irrigate", "school", "fire"]&lt;BR /&gt;arcpy.Intersect_analysis(inFeatures, finalParc, "NO_FID", "", "")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Join the Party table to the parcel with all the information from the layers.....&lt;BR /&gt;#Set the variables....&lt;BR /&gt;layerName = "finalParc"&lt;BR /&gt;joinField = "ASSESSOR_N"&lt;BR /&gt;arcpy.AddJoin_management(layerName, joinField, party, joinField)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully, this is enough information. &amp;nbsp;Thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2017 22:26:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-creating-list-with-append/m-p/155306#M11986</guid>
      <dc:creator>CynthiaKozma</dc:creator>
      <dc:date>2017-02-21T22:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: error creating list with append</title>
      <link>https://community.esri.com/t5/python-questions/error-creating-list-with-append/m-p/155307#M11987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you run a script outside of Arc*, it knows nothing about your working environment, you need to specify your working folder where your layers are located using arcpy.env = .....&lt;/P&gt;&lt;P&gt;I don't know if it matters, but your list isn't...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;layerList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"zoning"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"fldplain"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"compplan"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"fire"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"school"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"irrigate"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ressoils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"soils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"uga"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layerList&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Out&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; set&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And cycling through a set can cause some issues... like the order is out of whack&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; layerList&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;i&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
irrigate
compplan
uga
ressoils
fldplain
school
soils
fire
zoning&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;/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 08:15:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-creating-list-with-append/m-p/155307#M11987</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T08:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: error creating list with append</title>
      <link>https://community.esri.com/t5/python-questions/error-creating-list-with-append/m-p/155308#M11988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For good practice, I did put in arcpy.env = "D:\\....." at the beginning of my script. &amp;nbsp;I did have the variables zoning, etc hardcoded at the beginning. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found that I was missing this line....&lt;/P&gt;&lt;P&gt;layerName = arcpy.MakeFeatureLayer_management(finalParc, "finalParc")&lt;/P&gt;&lt;P&gt;before my AddJoin_management. &amp;nbsp;Think I have been looking at it too long. &amp;nbsp;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2017 23:17:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-creating-list-with-append/m-p/155308#M11988</guid>
      <dc:creator>CynthiaKozma</dc:creator>
      <dc:date>2017-02-21T23:17:44Z</dc:date>
    </item>
  </channel>
</rss>

