laptop and a wrench


The Calculate Field tool results in a NameError exception when using Python variables.

Last Published: October 28, 2015 ArcGIS for Desktop
Bug ID Number BUG-000091442
SubmittedOctober 15, 2015
Last ModifiedNovember 24, 2020
Applies toArcGIS for Desktop
Version found10.2.2
Operating SystemWindows
Operating System Version7.0 64 Bit
StatusKnown Limit

Additional Information

Changes were made around 10.2.2 to properly isolate script tool code, validation and tool like Calculate Field and Calculate Value that use Python internally. Prior to this change, there was potential for confusing and unexpected issues that would be hard to isolate because a variable could be changed in one tool that would impact another tool. The best strategy for passing variables into CalculateField is using string formatting as shown in the workaround.


Use the following code:arcpy.CalculateField_management(table,"gayu", "({0} + 1) / 2".format(funcg), "PYTHON", "")

Steps to Reproduce

Bug ID: BUG-000091442


  • ArcGIS for Desktop

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic