Hi all, I have a simple script that adds a field to a set of feature classesfor fc in fcList:
arcpy.AddField_management(fc,Source,FieldType2,fieldLength)
arcpy.AddMessage("Fields added...")
In the above example: Source, FieldType2, and fieldLength all refer back to variables containing the field name (sourcefile), the field type (text)and field Length (75)For the next step I want to cycle through the feature classes again. This time, populating the sourcefile field with the feature class name; in this case, it would be fc.for fc in fcList:
arcpy.CalculateField_management(fc,Source,"fc","PYTHON")
The first code snippet runs without error. The text field of length 75 is added.The second code snippet gives the following error:Traceback (most recent call last): File "T:\JOBS\123110494\gis_data\spatial_data\project_discipline\modeling\scripts\HWard\add_calc_dissolve.py", line 242, in <module> arcpy.CalculateField_management(fc,Source,"fc","PYTHON") File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 3129, in CalculateField raise eExecuteError: ERROR 000539: Error running expression: fc Traceback (most recent call last): File "<expression>", line 1, in <module>NameError: name 'fc' is not definedFailed to execute (CalculateField).Failed to execute (master).I've tried putting single quotes around fc ('fc'), tried it without quotes (fc), and even tried converting it to a string (str(fc)), but nothing seems to work.I've also tried replacing "fc" with "test", and I get the same error, but in that case, it tells me "test" does not exist.Any thoughts would be greatly appreciated.Thanks in advance-Z