First post here, please be gentle...
I use ArcMap 10.3.1 and I'm having trouble with part of a Python script which will always be run from the Current mxd and active data frame.
I have to pass a list of layers to a function. I have given the script a list of all potential layers for this function (List 1). Some of those potential layers will actually be in my active data frame (always at least 1), along with other layers that are not compatible with the next function (List2). I want to only work with the potential layers that are actually present in my active data frame (List3)
I've tried the following:
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = mxd.ActiveDataFrame
List 1 = ["September", "October", "November", "December"]
List 2 = arcpy.mapping.ListLayers(df) # layers are named September and December
List 3 = list(set.(List1).intersection(List2))
The result is an empty list when it should be September, December.
I think the syntax roughly works, but the problem is that List2 returns something similar to <layer u'September'> so the two layers with identical names are not recognized as such.
(For context, I'll then be using List3 to print unique messages depending on the layer name returned... In case this helps)
Can anyone help me out?