curtvprice

Using decorators for script tool interfaces?

Discussion created by curtvprice Champion on May 12, 2013
Latest reply on May 12, 2013 by lpinner
I saw a neat example this morning of Python decorators that made me think: could this be a nice way to set up a script tool interface for functions?

The way I set up tools now is as functions (so I can call them directly) and at the end of the code put something like this so I can use the file as a script tool:

if __name__ == "__main__":
  args = [arcpy.GetParameterAsText(i) for i in range(arcpy.GetParameterCount())]
  MyTool(*args)


Could this be done nicely with a decorator right above my function MyTool?

Outcomes