Did you ever wanted to run a tool in Python dynamically? Without "hard coding" the tool name and the parameters in a script?
This is the normal, static syntax to call a tool:
result = arcpy.Buffer_management("input", "output", 100)
If you need to run a tool depending on a condition, and you want to make the name and the parameters dynamic, you can use this syntax:
tool = "Buffer_management" arguments = ["input", "output", 100] result = getattr(arcpy, tool)(*arguments)
So the built-in gettattr-method calls the method tool with arguments as parameter values, the asterisk is used to unpack the list of arguments for the call of the tool.
A very interesting way of running a tool! I would not claim to be a python expert so probably showing my ignorance but I was wondering under what scenario would you ever run a tool in this manner? I've never seen this technique used in any of the ESRI help documentation.
Thanks for the tip.