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).
However, the error messages are telling me that my syntax is incorrect:
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.
code-block
; I just wanted a quick way to do a more complicated calculation thana + b
def test(var1): return var1*2
), then copy the code block and right-click in the interactive window choosing "Execute python code from clipboard", then test/debug the function with possible values forvar1
(e.g.,test(4)
should return 8). It's a pure Python method of developing and testing the code block before introducing it to ArcGIS.