Thursday, 10 August 2017

Troubleshooting ERROR 000989 Python syntax error from ArcGIS Field Calculator?


I'm trying to used the Python syntax in ArcGIS 10's field calculator and am thoroughly confused. So far the most basic calculations are failing me, and I don't understand why. I'm trying to create a function to just set the values of all cells in a column to be a multiple of the argument that I pass in ( I wanted to try something simple to test it out, as anything more complicated I tried also failed). enter image description here


However, the error messages are telling me that my syntax is incorrect:


enter image description here



but I can't understand what is incorrect.




As an aside, I'm also horrified at how hard it is to write readable python in the field calculator box as there is no syntax highlighting, or clear indentation. It would be quicker, and easier to write an external Python script to do this calculation, but I want to try to figure out how this new function worked within the program.



Answer



It might be because you're using a field name where a parameter name should go.


Instead, try something like:


def avg(paramName):
return 10

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...