arcpy.toolbox.tool vs arcpy.tool_toolbox

2769
6
08-05-2015 10:24 AM
ChrisMathers
Occasional Contributor III

Quick question for the python team. Whats the deal with this? Both arcpy.toolbox.tool and arcpy.tool_toolbox work but while the former is more pythonic, the later is what is pushed in the documentation.

Tags (1)
6 Replies
DanPatterson_Retired
MVP Emeritus

Chris...the python team might not visit here...so perhaps you could provide some links in the help file that you are referring to solicit some discussion

0 Kudos
ChrisMathers
Occasional Contributor III

Its any tool, ie Intersect—Help | ArcGIS for Desktop. Look at the syntax section, its tool_toolbox. I am not sure where I saw it (it was a long time ago) but in the arcpy docs somewhere it specifically said you can use either syntax. It works because Ive used both. It never occurred to me to ask but I randomly thought of it today.

0 Kudos
DanPatterson_Retired
MVP Emeritus

No I kind of see what you mean like...

arcpy.sa.FocalStatistics versus arcpy.FocalStatistics_sa  in the spatial analyst extension

If you were using intellisense, then the first approach is what would pop up at the command line since it would be the arcpy package, the spatial analyst module and the FocalStatistics function​.  I always think that as being more logical...like dates... 2015-08-06  21:12:00 makes more sense to me for date and time

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Did it come into play during the (9.x?) gp. to (10.x) arcpy. transition?

0 Kudos
ChrisMathers
Occasional Contributor III

Im not sure. Looking at the 9.3 docs the syntax is also given as .tool_toolbox but I do not have a way to test if the other syntax works with the pre 10 geoprocessor. It could be that the arcgisscripting module was organized so that everything was a function of the geoprocessor class where arcpy has classes for each toolbox. If I was at work I would look at the arcpy source. Arcpy may just repackage the tool name and inputs as command line for the geoprocessor core, which is in C, but it still needs every tool in there somehow for doc strings and such.

0 Kudos
ChrisMathers
Occasional Contributor III

Exactly. The arcpy sitepackage is the only python module Ive seen with this sort of syntax available.

0 Kudos