Can some one please let me know how I can do simple field calculation like Copying From "A" to "B" in ArcPy?

I have found lots os example on web which they all used extra expression and they were complicated.what I need is simply doing what we can do in ArcMap GUI like

B = !A!


Here is the code I have so far but I am getting error on running this as

NameError: name 'A' is not defined

point_shp = "G:\\Temp\\All_Provinces.shp"
arcpy.AddField_management(point_shp, "B", "TEXT", "", "", "25", "", "NON_NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(point_shp, "B", "A", "PYTHON_9.3")

1 Answer 1


I got it, the A must be wrapped like "!A!"

arcpy.CalculateField_management(point_shp, "B","!A!", "PYTHON_9.3")
  • 4
    If you solved your own question, please accept it so others will not think it still unresolved.
    – Barbarossa
    Jan 14, 2014 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.