laptop and a wrench

Bogue

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

Dernière publication: October 28, 2015 ArcGIS for Desktop
Numéro d’ID de bogue BUG-000091442
EnvoiOctober 15, 2015
Dernière modificationJune 5, 2024
S’applique àArcGIS for Desktop
Version trouvée10.2.2
Système d’exploitationWindows OS
Version du système d’exploitation7.0 64 Bit
StatutKnown Limit

Informations supplémentaires

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.

Solution de contournement

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

Étapes pour reproduire

ID de bogue: BUG-000091442

Logiciel:

  • ArcGIS for Desktop

Recevoir une notification lorsque le statut d’un bogue change

Télécharger l’application Esri Support

En savoir plus sur ce sujet

Obtenir de l’aide auprès des experts ArcGIS

Contacter le support technique

Télécharger l’application Esri Support

Accéder aux options de téléchargement