AnsweredAssumed Answered

Error accessing dictionary values

Question asked by recurvata on Dec 8, 2014
Latest reply on Dec 10, 2014 by recurvata

In the code below, line 14,  'alias = dict[]', always throws an exception. I don't see why; printing out works just fine. Also, the exception message is the field name printing correctly.

Printing the dictionary keys and values also works fine. The ultimate goal is to get a string to set as the field alias using AlterField. Thanks.


with arcpy.da.SearchCursor(metatable, metaflds) as rows:
        for row in rows:
            if not moe in row[1]:
                fn = row[1].replace(' ', '')
                fn = fn.replace(est, '')
                dict[row[0]] = fn

    # Get list of tables to add alias to
    tbls = arcpy.ListTables()
    for tbl in tbls:
        tblflds = arcpy.ListFields(tbl)
        for fld in tblflds:
                alias = dict[]   # exception raised here
            except Exception as e:
                import traceback
                import sys
                tb = sys.exc_info()[2]
                print('Oh no!')
                print("Line {0}".format(tb.tb_lineno))