laptop and a wrench

Bug

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 ModifiedJune 5, 2024
Applies toArcGIS for Desktop
Version found10.2.2
Operating SystemWindows OS
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.

Workaround

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

Steps to Reproduce

Bug ID: BUG-000091442

Software:

  • ArcGIS for Desktop

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options