I have a list of layers (
.ListLayers()) taken from a dataframe
. In my case the layers can have two types of data source either shapefile or GDB. I want to start different actions depending on the source type. What I thought of so far: it would be possible to compare the 'desc.name[-4:]' with '".shp"' like:
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "") lyrlist = arcpy.mapping.ListLayers(mxd, "", df) for lyr in lyrlist: desc = arcpy.Describe(lyr) if (desc.name[-4:] == ".shp"): #do something with the shapefile else: #do something with the GDB feature class)
I still believe this option must be hidden somewhere in the describe method.
Is it possible to distinguish shapefiles from geodatabase feature class with the arcpy describe() method?