Problems understanding code aimed at turning layers on/off

Discussion created by geord359 on Jun 26, 2014
Latest reply on Jun 26, 2014 by AdamCox

I am still relatively new to Python and have trouble understanding lines/parts of certain scripts. I am interested in developing a tool that can turn certain layers off and would appreciate a little help understanding a script I found on another forum.

In the script shown below I can understand most sections apart from lines 5 and 6. I don't really get what the [0] stands for or is referring to, I do not know what the "*" is for, and more importantly I don't fully understand how these two lines interact with the rest of the script.

names = [x,y,z,etc]

mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(, mxd, "Layers")[0]
layers = arcpy.mapping.ListLayers(mxd, "*", df)

for layer in layers:
  if in names:
    layer.visible = False


I would appreciate any guidance anyone can provide.