Python Script From ArcGis Training.

Discussion created by bem08c on Apr 23, 2014
Latest reply on Apr 23, 2014 by hua17
I have been doing some of the python training from ESRI and i am running into a problem with one of the scripts they are having me use. The script is directly from the training page. From my understanding the reason that this won't work is that mapDoc isnt defined. Is it the training that has an error in it? The script updates layer files for a map.

>>> path = r"C:\Users\mittler_b\Desktop\Misc\MapScripting10_0\Maps\\"
... arcpy.env.workspace = path
... sourceLyr = arcpy.mapping.Layer(r"C:\Users\mittler_b\Desktop\Misc\MapScripting10_0\NewParks.lyr")
... for mapdoc in arcpy.ListFiles("*.mxd"):
...     print mapDoc
...     mxd = arcpy.mapping.MapDocument(path + mapDoc)
...     for df in arcpy.mapping.ListDataFrame(mxd):
...         updateLyr = arcpy.mapping.ListLayers(mxd, "Parks", df)[0]
...         arcpy.mapping.UpdateLayer(df, updateLyr, sourceLyr)