<?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: Automatically updating variables inside a for loop in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522667#M40988</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course!&amp;nbsp;&amp;nbsp; I can't try this out yet but I bet this is the solution!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jun 2015 13:28:56 GMT</pubDate>
    <dc:creator>RachaelJohnson</dc:creator>
    <dc:date>2015-06-12T13:28:56Z</dc:date>
    <item>
      <title>Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522660#M40981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This question is back to basics; I looked around for an answer or a clue and I can't find what I'm looking for.&amp;nbsp; I'm stuck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got 3 variables with assigned string values (shapefile paths) and I am running them through a loop to check that their projected coordinate systems (PCS) are the same as my DEM's PCS.&amp;nbsp; I want the code to check if they're the same, and if not, I want to project the file and reassign the projected file path to the original variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;print("Verifying that coordinate systems are the same...")
InSHP = [outline, DA, soil]
DEMSR = arcpy.Describe(DEM).spatialReference.PCSCode
for i, l in enumerate(InSHP):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print InSHP&lt;I&gt;&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sr = arcpy.Describe(l).spatialReference.PCScode
&amp;nbsp;&amp;nbsp;&amp;nbsp; if sr != DEMSR:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l = arcpy.Project_management(l, l[:-4] + "PRJ.shp", DEMSR)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InSHP&lt;I&gt; = l&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print InSHP&lt;I&gt;&lt;/I&gt;
print outline&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print InSHP&lt;I&gt; produces the modified file path but print outline does not.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, &lt;SPAN style="font-family: 'courier new', courier;"&gt;l&lt;/SPAN&gt; = the projected shapefile but the&lt;SPAN style="font-family: 'courier new', courier;"&gt; l&lt;/SPAN&gt; doesn't automatically connect the original variable name (&lt;SPAN style="font-family: 'courier new', courier;"&gt;outline&lt;/SPAN&gt;) to the new path.&amp;nbsp; I was initially expecting the program to automatically deduce that &lt;SPAN style="font-family: 'courier new', courier;"&gt;l&lt;/SPAN&gt; = new path = &lt;SPAN style="font-family: 'courier new', courier;"&gt;outline&lt;/SPAN&gt;, which was kind of stupid of me to think in retrospect.&amp;nbsp; Now I explicitly know that &lt;SPAN style="font-family: 'courier new', courier;"&gt;l&lt;/SPAN&gt; only refers to the entry in the list and is in no way connected to the original variable aside from having the same starting values.&amp;nbsp; Is there a way to automate this sort of assignment or am I doomed to adding the following at the end of my code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;outline = InSHP[0]
DA = InSHP[1]
soil = InSHP[2]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess it's not a big deal because there's only 3 of them but what if I need to check more inputs?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a side question, this loop tells me that my soils file does not have a PCS, but when I look at the file properties in GIS or Catalog, it does have a PCS.&amp;nbsp; Any idea why that's happening?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: line-through;"&gt;EDIT: Ugh.&amp;nbsp; Adding those next 3 lines at the end didn't actually accomplish what I wanted it to accomplish.&amp;nbsp; I'm so used to working with cursors and GIS tables that my plain list skills are lacking. :S &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT 2: Okay I got my list to update using the enumerate function and I updated my code accordingly.&amp;nbsp; My original question(s) still stand, though.&amp;nbsp; Is there a way to assign the new values to the original variables names without having to explicitly type the variable names again?&amp;nbsp; I'm starting to think there isn't but I already posted this and I'm going to keep it here in case any other novice has this same problem.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:47:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522660#M40981</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2021-12-11T22:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522661#M40982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are assigning the projected shapefile to l, this doesn't modify the original variable in your list.&amp;nbsp; When you assign a variable to another variable you are actually making a copy of the original.&amp;nbsp; Somewhere in your code you are assigning a path name to outline.&amp;nbsp; You then create a list that contains variables.&amp;nbsp; You run that list through a for loop that takes the contents of that list one at a time and makes a copy of its contents in l.&amp;nbsp; Changing l doesn't change the original variable.&amp;nbsp; In fact if you change InSHP[0], it won't change the original contents in the outline variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "This"
&amp;gt;&amp;gt;&amp;gt; b = "That"
&amp;gt;&amp;gt;&amp;gt; c = "The Other"
&amp;gt;&amp;gt;&amp;gt; these = [a, b, c]
&amp;gt;&amp;gt;&amp;gt; print these
['This', 'That', 'The Other']
&amp;gt;&amp;gt;&amp;gt; these[0] = "Now This"
&amp;gt;&amp;gt;&amp;gt; print these
['Now This', 'That', 'The Other']
&amp;gt;&amp;gt;&amp;gt; print a
This
&amp;gt;&amp;gt;&amp;gt; for x in range(0, 3):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print x

&amp;nbsp;&amp;nbsp; 
0
1
2
&amp;gt;&amp;gt;&amp;gt; print x
2&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might be better to make a for loop like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for x in range(0, len(InSHP)):
&amp;nbsp; sr = arcpy.Describe(InShP&lt;X&gt;).spatialReference.PCScode&lt;/X&gt;
&lt;SPAN class="keyword"&gt;&amp;nbsp; print(InSHP&lt;X&gt;, sr)&amp;nbsp; &lt;/X&gt;&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword"&gt;if sr != DEMSR:&amp;nbsp; &lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InSHP&lt;X&gt; = arcpy.Project_management(InSHP&lt;X&gt;, InSHP&lt;X&gt;[:-&lt;SPAN class="number"&gt;4] + &lt;SPAN class="string"&gt;"PRJ.shp"&lt;/SPAN&gt;, DEMSR) &lt;/SPAN&gt;&lt;/X&gt;&lt;/X&gt;&lt;/X&gt;
&lt;SPAN class="keyword"&gt;print InSHP[0]&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:47:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522661#M40982</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2021-12-11T22:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522662#M40983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is that code you posted preferable to my current code using enumerate?&amp;nbsp; Your code still requires me to update the variables manually outside of the loop, correct?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 15:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522662#M40983</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2015-06-10T15:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522663#M40984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure this is do-able but it's a little difficult to make a recommendation without seeing your whole code. In particular, it would be useful to see the original definitions for your three variables and a little more information about how you intend to use them later in the script. (One approach may be to have "before" and "after" variables, or something like that.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would be careful about trying to re-assign l while inside that loop (and in any case, just working off the top of my head, I'm not sure Project_management returns a value you can or would want to use that way anyway, though I'd be grateful to stand corrected on that).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 15:47:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522663#M40984</guid>
      <dc:creator>andysp</dc:creator>
      <dc:date>2015-06-10T15:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522664#M40985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These are my original inputs:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;outline = r"K:\GradWork\GIS\CollegePark\CP_outline.shp"
DA = r"K:\GradWork\GIS\CollegePark\CPDrainage.shp"
DAID = "Id"&amp;nbsp; # field in DA shapefile where unique DA values exist
soil = r"C:\Users\Rachael Johnson\Documents\GradWork\Project Files\BMPGIS\soils\VB_Soils.shp"
WTin = r"K:\GradWork\GIS\CollegePark\CPGW_adj1"
DEMin = r"K:\GradWork\GIS\CollegePark\cpelev"
MapLoc = r"K:\GradWork\GIS\CollegePark\CP.mxd"
WT = arcpy.Raster(WTin)
DEM = arcpy.Raster(DEMin)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code uses these inputs in the context of other arcpy functions to create new variables or set environments.&amp;nbsp; The outline variable, for example, is used here and then isn't used again:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;### _____________SET PROCESSING EXTENTS____________ ###
# Set cell size
description = arcpy.Describe(DEM)
cellsize = description.children[0].meanCellHeight
print("Setting cell size to DEM cell size: " + str(cellsize) + " ft...")
arcpy.env.cellSize = cellsize


# Create buffer around outline to use as mask
# Buffer distance is in feet
print("Creating an environment mask from the site outline shapefile...")
maskshp = arcpy.Buffer_analysis(outline, ScratchPath + r"\outline_buff", "50 Feet", "", "", "ALL",)


# Convert buffer to raster
mask = arcpy.Raster(arcpy.PolygonToRaster_conversion(maskshp, "Id", ScratchPath + r"\rastermask"))
mask.save(ScratchPath + r"\rastermask")


# Set raster mask and snap raster
print("Setting raster mask and snap raster for project...")
arcpy.env.mask = mask
arcpy.env.snapRaster = mask
arcpy.env.extent = mask.extent&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an example of using one of the inputs to create a new variable and how that new variable is later transformed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Convert soils shapefile to raster and assign integer values to HSG.
# A=1, B=2, C=3, 4=D and dual groups A/D=14, B/D=24, C/D=34
# "---" is treated as a D soil
print("Converting dual group soils to single groups...")
SoilUnclass = arcpy.PolygonToRaster_conversion(soil, "HSG", ScratchPath + r"\SoilUnclass",
&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;&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; "MAXIMUM_COMBINED_AREA")
SoilClass = arcpy.sa.Reclassify(SoilUnclass, "HSG", arcpy.sa.RemapValue([["A", 1],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["B", 2],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["C", 3],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["D", 4],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["A/D", 14],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["B/D", 24],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["C/D", 34],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["---", 4]]), "NODATA")
SoilClass.save(ScratchPath + r"\HSGraster")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Project_management does return a variable that I can use in that way; with most of these arcpy functions, setting a variable to them and then calling the variable prints the file path of the resulting shapefile or grid.&amp;nbsp; So, in the context of the above code, "print SoilClass" returns the path "K:\GradWork\GIS\CollegePark\CP\scratch\HSGraster".&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522664#M40985</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2021-12-11T22:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522665#M40986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would this kind of construct be useful?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;my_layers = [&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; ['outline','K:\GradWork\GIS\CollegePark\CP_outline.shp'],\
&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; ['DA','K:\GradWork\GIS\CollegePark\CPDrainage.shp'],\
&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; ['soil','C:\Users\Rachael\VB_Soils.shp']\
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]

for layer in my_layers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'debug 1 key: ' + layer[0] + ' value: ' + layer[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # this is just an arbitrary test; you might test for PCS equivalency here
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if layer[1] == '&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;C:\Users\Rachael\VB_Soils.shp':&lt;/SPAN&gt;
&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer[1] = 'C:\Users\Rachel\New_File_Name.shp'&lt;/SPAN&gt;
&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'debug 2 key: ' + layer[0] + ' value: ' + layer[1]&lt;/SPAN&gt;

&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;for resulting_layer in my_layers:&lt;/SPAN&gt;
&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'debug 3 key: ' + resulting_layer[0] + ' value: ' + resulting_layer[1]&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;debug 1 key: outline value: K:\GradWork\GIS\CollegePark\CP_outline.shp
debug 2 key: outline value: K:\GradWork\GIS\CollegePark\CP_outline.shp
debug 1 key: DA value: K:\GradWork\GIS\CollegePark\CPDrainage.shp
debug 2 key: DA value: K:\GradWork\GIS\CollegePark\CPDrainage.shp
debug 1 key: soil value: C:\Users\Rachael\VB_Soils.shp
debug 2 key: soil value: C:\Users\Rachel\New_File_Name.shp
debug 3 key: outline value: K:\GradWork\GIS\CollegePark\CP_outline.shp
debug 3 key: DA value: K:\GradWork\GIS\CollegePark\CPDrainage.shp
debug 3 key: soil value: C:\Users\Rachel\New_File_Name.shp&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:47:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522665#M40986</guid>
      <dc:creator>andysp</dc:creator>
      <dc:date>2021-12-11T22:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522666#M40987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use a dict instead of a list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Verifying that coordinate systems are the same...")&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; InSHP = {'outline':outline, 'DA':DA, 'soil':soil}&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; DEMSR = arcpy.Describe(DEM).spatialReference.PCSCode&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for l in InSHP:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print l, InSHP&lt;L&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sr = arcpy.Describe(InSHP&lt;L&gt;).spatialReference.PCScode&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sr != DEMSR:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InSHP&lt;L&gt; = arcpy.Project_management(InSHP&lt;L&gt;, InSHP&lt;L&gt;[:-4] + "PRJ.shp", DEMSR)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print InSHP&lt;L&gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print InSHP['outline']&lt;/L&gt;&lt;/L&gt;&lt;/L&gt;&lt;/L&gt;&lt;/L&gt;&lt;/L&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:47:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522666#M40987</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-11T22:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522667#M40988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course!&amp;nbsp;&amp;nbsp; I can't try this out yet but I bet this is the solution!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 13:28:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522667#M40988</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2015-06-12T13:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically updating variables inside a for loop</title>
      <link>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522668#M40989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good call, Luke.&amp;nbsp; I was going to recommend the same but didn't have time to get back to replying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS - You need a curly brace instead of a square bracket at the end of your dictionary assignment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:26:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/automatically-updating-variables-inside-a-for-loop/m-p/522668#M40989</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2015-06-12T14:26:05Z</dc:date>
    </item>
  </channel>
</rss>

