<?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: &amp;quot;IndexError: list index out of range&amp;quot; - when trying to Update Layer in ArcPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398375#M31438</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jeff-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, being new to Python...&amp;nbsp; What is the difference between a Layer Object and Python List Object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not seeing anything different in your two lines that you posted that would differentiate between the two?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Oct 2011 14:26:28 GMT</pubDate>
    <dc:creator>KateNewell</dc:creator>
    <dc:date>2011-10-07T14:26:28Z</dc:date>
    <item>
      <title>&amp;amp;quot;IndexError: list index out of range&amp;amp;quot; - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398367#M31430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to run (what I thought) was a very simple script that updates the symbology in a Layer File based on another layer file. Being very new to Python, I "lifted" some example code straight from the ArcGIS10 help ( &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/UpdateLayer/00s30000003p000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/UpdateLayer/00s30000003p000000/&lt;/A&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The layer file to be updated in my map document is part of a grouped layer file within a grouped layer file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I keep getting an IndexError and I have no idea why!?! There is only one dataframe (Layers). Any help is greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"N:\Templates\v10\Base Maps\A_Portrait.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateLayer = arcpy.mapping.ListLayers(mxd, "Base Map Layers\Bay, Lakes &amp;amp; Streams", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sourceLayer = arcpy.mapping.Layer(r"N:\Users\ke\Bay, Lakes &amp;amp; Streams.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.save()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd, sourceLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and this is the error message that I get:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;====&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-style: italic;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-style: italic;"&gt;File "N:\Users\ke\ArcPyMapping\UpdateLayerFile.py", line 4, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-style: italic;"&gt;updateLayer = arcpy.mapping.ListLayers(mxd, "Base Map Layers\Bay, Lakes &amp;amp; Streams", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-style: italic;"&gt;IndexError: list index out of range&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 22:07:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398367#M31430</guid>
      <dc:creator>KateNewell</dc:creator>
      <dc:date>2011-10-05T22:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398368#M31431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Since you are specifying exctly what layer you are interested in ("Base Map Layers\Bay, Lakes &amp;amp; Streams"), try leaving the [0] index off. The [0] being a refrence to the 1st item in a list, but this time you are only expecting one item anyway...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So instead of: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateLayer = arcpy.mapping.ListLayers(mxd, "Base Map Layers\Bay, Lakes &amp;amp; Streams", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateLayer = arcpy.mapping.ListLayers(mxd, "Base Map Layers\Bay, Lakes &amp;amp; Streams", df)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If that idea doesn't work try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateLayer = arcpy.mapping.ListLayers(mxd, r"Base Map Layers\Bay, Lakes &amp;amp; Streams", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;instead of&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateLayer = arcpy.mapping.ListLayers(mxd, "Base Map Layers\Bay, Lakes &amp;amp; Streams", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since Python doesn't like the "\" symbol... You need to either use "\\", "/", or my favorite r"\". &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I have seen weird things happen then map layers contain special characters such as "&amp;amp;".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope something here helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 22:17:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398368#M31431</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-10-05T22:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398369#M31432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply Chris.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunatly none of that seemed to work.&amp;nbsp; When I added \\ or r"\", the same message appeared.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However when I removed the [0] from line four, I got a totally new error message (which is even more confusing!):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-style: italic;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "N:\Users\ke\ArcPyMapping\UpdateLayerFile.py", line 6, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 181, in fn_&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fn(*args, **kw)&lt;BR /&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\mapping.py", line 1458, in UpdateLayer&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert isinstance(update_layer, Layer)&lt;BR /&gt;AssertionError&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 22:29:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398369#M31432</guid>
      <dc:creator>KateNewell</dc:creator>
      <dc:date>2011-10-05T22:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398370#M31433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try renaming your layer to some simple name that doesn't have a &amp;amp; or \ symbol in it (like "mylayer"), and then try running the code like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;updateLayer = arcpy.mapping.ListLayers(mxd, "mylayer", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does that work? If so, my guess is that arcpy doesn't like the \ or &amp;amp; symbol in your layer name...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 22:34:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398370#M31433</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-10-05T22:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398371#M31434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Still no luck.&amp;nbsp; Changed it to remove all the &amp;amp; and \ and the same error message persisted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much for the suggestions and warnings though....&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hmmmm....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 22:43:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398371#M31434</guid>
      <dc:creator>KateNewell</dc:creator>
      <dc:date>2011-10-05T22:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398372#M31435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Kate,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm no expert on arcpy's mapping module, but I couldn't help myself!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your first and second error messages seem consistent to me: your code dies the first time on the arcpy.mapping.ListLayers call, which returns a list of layers that suit the filter, or an empty list '[]' if no results are found. I think your filter is returning an empty list (no values found), and so the function is trying to return the first element of your empty list, which kills it with an IndexError.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;[][0] = DEAD&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, by removing the [0], the function successfully passes on the empty list to the arcpy.mapping.UpdateLayer, which dies because it's being handed an empty list to work on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.mapping.UpdateLayer(df, [], sourceLayer, True) = DEAD&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would recommend calling arcpy.mapping.ListLayers with the mxd &lt;/SPAN&gt;&lt;STRONG&gt;and no filter&lt;/STRONG&gt;&lt;SPAN&gt;, to see what name is being assigned to your layer. The List methods in arcpy are relatively fickle and need an exact match of the value being searched for, or at lest wildcards around them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example: shapethingy.shp will not appear under ListFeatureClasses(filter) if filter = &lt;/SPAN&gt;&lt;STRONG&gt;'shapethingy'&lt;/STRONG&gt;&lt;SPAN&gt;, but but will if filter = &lt;/SPAN&gt;&lt;STRONG&gt;'shapethingy*'&lt;/STRONG&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;STRONG&gt;'shapethingy.shp'&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, if this is your only layer, you don't even need to add in a filter: just call the layer directly by name in your other functions (since the only thing being passed around by ListLayers is a string, not an object)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.mapping.UpdateLayer(df, "LAYERS", sourceLayer, True)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Oct 2011 16:40:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398372#M31435</guid>
      <dc:creator>MarcNakleh</dc:creator>
      <dc:date>2011-10-06T16:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398373#M31436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I finally got it to work, and the trick was putting it into a "for" loop. I still really don't understand the whole index thing, and I'm very new to Python, but this was the only way I could force it to find "Bay, Lakes &amp;amp; Streams"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I take the [0] off, it would still fail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code that works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"N:\Templates\v10\Neighborhood Templates\York_NhoodMap.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateLayer = arcpy.mapping.ListLayers(mxd, r"Bay, Lakes &amp;amp; Streams", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sourceLayer = arcpy.mapping.Layer(r"N:\Users\ke\BayLake.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in arcpy.mapping.ListLayers(mxd, "Bay, Lakes &amp;amp; Streams", df):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd, sourceLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for everyones tips and tricks : )&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Oct 2011 18:27:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398373#M31436</guid>
      <dc:creator>KateNewell</dc:creator>
      <dc:date>2011-10-06T18:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398374#M31437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When using List functions in arcpy.mapping you will always need to use the index number at the end:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myLayer = arcpy.mapping.ListLayers(mxd, "filter")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will return a layer object&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myLayer = arcpy.mapping.ListLayers(mxd, "filter")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will return a Python list object&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also - there way most likely a typo in your filter.&amp;nbsp; Try using wildcard.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myLayer = arcpy.mapping.ListLayers(mxd, "Bay, Lakes*")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Oct 2011 13:52:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398374#M31437</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2011-10-07T13:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398375#M31438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jeff-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, being new to Python...&amp;nbsp; What is the difference between a Layer Object and Python List Object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not seeing anything different in your two lines that you posted that would differentiate between the two?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Oct 2011 14:26:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398375#M31438</guid>
      <dc:creator>KateNewell</dc:creator>
      <dc:date>2011-10-07T14:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398376#M31439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jeff (while I got ya here ; )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I used the index of [0], isn't this just calling the first returned object in the list?&amp;nbsp; My "Bays, Lakes &amp;amp; Streams" grouped layer file is way at the bottom of my table of contents...which I would think would mean that instead of [0] I would be calling [21], which when I ran the "Longname" command and counted it's place, that is where it was...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help.&amp;nbsp; I did attend a conference where you were doing hands-on ArcPy.mapping workshop almost a year ago in Tacoma, unfortunately we only just finally got 10 installed so I'm just now trying to dive into using ArcPy.mapping.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Oct 2011 14:33:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398376#M31439</guid>
      <dc:creator>KateNewell</dc:creator>
      <dc:date>2011-10-07T14:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: "IndexError: list index out of range" - when trying to Update Layer in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398377#M31440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My mistake.&amp;nbsp; I included the [0] accidentally.&amp;nbsp; Let me try again:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myLayerObj = arcpy.mapping.ListLayers(mxd, "filter")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This returns a layer object&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myLayerListObj = arcpy.mapping.ListLayers(mxd, "filter")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This returns a Python list object.&amp;nbsp; If you want to get to items in the list you need to either use and index number or a for loop.&amp;nbsp; If your MXD is designed with all layers having unique names, then if you use the correct filter, you will only have one item in your list and you can use [0] to extract it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a new arcpy.mapping tutorial that covers this in much better detail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Getting_started_with_arcpy_mapping_tutorial/00s30000006w000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Getting_started_with_arcpy_mapping_tutorial/00s30000006w000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 01:03:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-indexerror-list-index-out-of-range/m-p/398377#M31440</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2011-10-09T01:03:34Z</dc:date>
    </item>
  </channel>
</rss>

