j256

arcpy.mapping.ListDataFrames - why the array index [0] on the end?

Discussion created by j256 on Dec 1, 2011
Latest reply on Dec 5, 2011 by arekmatoszka
Can someone please explain why we need to do this:

df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]


instead of just:

df = arcpy.mapping.ListDataFrames(mxd, "Layers")


If I just say
df = arcpy.mapping.ListDataFrames(mxd)
then I can loop through the df list object by doing something like
for i in df:
  print i.name


But if I want to set variable df to a known data frame (in this case "Layers") why do I need to specify the index number [0] at the end of the code line?

If anyone can explain this quirk I'd be really grateful. Thanks

Outcomes