Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Using decorators for script tool interfaces?

$
0
0
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:

Code:

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?

Viewing all articles
Browse latest Browse all 2485

Trending Articles