OK, folks. Thanks to your help, I've learned enough to solve the problem. I'll put the code below, but first a couple of comments, which hopefully will help anyone who is trying to solve similar problems who comes across this thread:
First, @JohannesLindner 's point is critical for any of this: the problem I'm trying to solve involves working with featureclasses, not featurelayers! So my opening sentence from my query is completely mis-stated. It reads "I've got a gdb containing many many layers...". In fact the situation is that I've got a gdb containing many many feature classes!
Second, my initial query describes what I needed to do as "merge" these classes. There is a tool called merge in arcpy, and it probably could be used to do what I needed done. But it is documented in a way that (at least for me), made it hard to distinguish some of the critical steps involved. The tool that I was able to make work is called "append". It has the advantage that the example arcpy code in its documentation is solving EXACTLY THE SAME PROBLEM I was trying to solve!
Finally, a key challenge in the problem I was trying to solve is to write the code in a way that allows for carefully keeping track and displaying how the fields from multiple classes that are hold the same data have different names. What you'll see in the code below is that I've tried to solve this problem by creating a python class that will hold the critical data about how fields are named for each arcgis class. I then create an instance of this class corresponding to each featureclass, and loop through that, pulling the relevant data from each one as needed. The key python trick in making this all work is liberal use of `getattr()` inside the loops! The structure of the code is exactly the same as in the code example for "append", except that what I've written iterate through lists of the relevant featureclasses and fields.
What you'll see below is the code for just two featureclasses. In reality, I'm have to append data from thirty!...but the real code is too long to post here!
#set the workspace to the gdb holding the features for each municipality
arcpy.env.workspace = ###OMITTED###
#create the receiving featureclass
cw_fc = arcpy.CreateFeatureclass_management(
out_path=###OMITTED###,
out_name="countywide.shp",
geometry_type="POLYGON",
spatial_reference=###OMITTED###
)
arcpy.management.AddField(
in_table=cw_fc,
field_name="MUNICIPALI",
field_type="TEXT",
field_alias="MUNICIPALI"
)
arcpy.management.AddField(
in_table=cw_fc,
field_name="ZONE_ABBR",
field_type="TEXT",
field_alias="ZONE_ABBR"
)
arcpy.management.AddField(
in_table=cw_fc,
field_name="ZONING",
field_type="TEXT",
field_alias="ZONING"
)
#define the class of objects that will hold the data we need for each successive input class
class InLayer():
def __init__(self, layer, muniNM, zone_abbrNM, zoningNM) :
self.layer = layer
self.MUNICIPALI = muniNM
self.ZONE_ABBR = zone_abbrNM
self.ZONING = zoningNM
#enter the data (only 2 classes here...the real one will contain 30)
inlayers = [
InLayer(
layer = 'Brighton_Zoning',
muniNM = "MUNICIPALITY",
zone_abbrNM = "ZONE_ABBR",
zoningNM = "ZONING"
),
InLayer(
layer = 'Brockport_Zoning',
muniNM = "MUNICIPALITY",
zone_abbrNM = "ZONE_ABBR",
zoningNM = "ZONING"
)
]
#create fieldmappings object for appending this layer
fieldmappings = arcpy.FieldMappings()
#add the target shp to the field mappings to set the schema
fieldmappings.addTable(cw_fc)
#Loop through the fields that need to be mapped
for fld in ["MUNICIPALI", "ZONE_ABBR", "ZONING"] :
#create a fieldmap
fldMap = arcpy.FieldMap()
#loop through the layers populate the input side of the fieldmap
for lyr in inlayers :
#add the input field for the current layer
fldMap.addInputField(lyr.layer, getattr(lyr,fld))
#set the output field name
oname = fldMap.outputField
oname.name, oname.aliasName, oname.type = fld, fld, "TEXT"
fldMap.outputField = oname
#add the outputfield to the fieldmappings object
fieldmappings.addFieldMap(fldMap)
#It should now be the case that fieldmappings is populated with all of the relevant inputs, matched to the appropriate outputs!
#so...append!
arcpy.Append_management(
inputs=[getattr(lyr, "layer") for lyr in inlayers],
target=###OMITTED###,
schema_type="NO_TEST",
field_mapping=fieldmappings,
subtype=""
)