If you create and recreate locators like I do, you can run the tool once and then copy the parameters so you can put them into a python script for automation In this case I'm creating a locator using street centerlines with an alt names table.
I paste them into a text editor to pretty them up a bit, and then copy that into my python IDE. In the end it looks like this:
def createCenterlinesLocator(scratchGDB,locatorsDir):
countryCode = 'USA'
primaryData = '{}\\Centerlines StreetAddress'.format(scratchGDB)
fieldMapping = "'StreetAddress.STREET_NAME_JOIN_ID Centerlines.JOINID';\
'StreetAddress.HOUSE_NUMBER_FROM_LEFT Centerlines.FROMADDR_L';\
'StreetAddress.HOUSE_NUMBER_TO_LEFT Centerlines.TOADDR_L';\
'StreetAddress.HOUSE_NUMBER_FROM_RIGHT Centerlines.FROMADDR_R';\
'StreetAddress.HOUSE_NUMBER_TO_RIGHT Centerlines.TOADDR_R';\
'StreetAddress.STREET_PREFIX_DIR Centerlines.PREDIR';\
'StreetAddress.STREET_NAME Centerlines.NAME';\
'StreetAddress.STREET_SUFFIX_TYPE Centerlines.POSTTYPE';\
'StreetAddress.STREET_SUFFIX_DIR Centerlines.POSTDIR'"
outLocator = '{}\\Centerlines_Pro'.format(locatorsDir)
languageCode = 'ENG'
altNames = '{}\\CenterlinesAltNames AlternateStreetName'.format(scratchGDB)
altFieldMapping = "'AlternateStreetName.STREET_NAME_JOIN_ID CenterlinesAltNames.JOINID';\
'AlternateStreetName.STREET_PREFIX_DIR CenterlinesAltNames.PREDIR';\
'AlternateStreetName.STREET_NAME CenterlinesAltNames.AN_NAME';\
'AlternateStreetName.STREET_SUFFIX_TYPE CenterlinesAltNames.POSTTYPE';\
'AlternateStreetName.STREET_SUFFIX_DIR CenterlinesAltNames.AN_POSTDIR'"
try:
arcpy.geocoding.CreateLocator(countryCode,primaryData,fieldMapping,outLocator,languageCode,
altNames,altFieldMapping)
print('Success: created single role centerlines locator')
except Exception as err:
print (err)
print('Error: unable to create single role centerlines locator. Exiting' )
time.sleep(5)
exit()
That should just about do it....