Why DeleteField_management vs DeleteField?

1946
1
08-15-2011 03:27 PM
RandyKreuziger
Regular Contributor
I've been porting scripts from 9.2 to 10.0 and finding I have to add "_management" onto the end of many of the tools.  Why is that?  The scripts all worked in 9.2 and 9.3.  I'm sure the answer is going to be real simple. 

# 10.0 Code
# Load required toolboxes...
ARCGISHOME="C:/Program Files/ArcGIS/Desktop10.0/"
arcpy.AddToolbox(ARCGISHOME+"ArcToolbox/Toolboxes/Data Management Tools.tbx")
arcpy.AddToolbox(ARCGISHOME+"ArcToolbox/Toolboxes/Analysis Tools.tbx")
arcpy.DeleteField_management

vs

# 9.3 Code
# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx")
gp.deletefield
0 Kudos
1 Reply
DaleHoneycutt
Regular Contributor
You don't need any of these AddToolBox calls:
# 10.0 Code
# Load required toolboxes...
ARCGISHOME="C:/Program Files/ArcGIS/Desktop10.0/"
arcpy.AddToolbox(ARCGISHOME+"ArcToolbox/Toolboxes/Data Management Tools.tbx")
arcpy.AddToolbox(ARCGISHOME+"ArcToolbox/Toolboxes/Analysis Tools.tbx")


System tools are automatically found.  It's only custom toolboxes that need to be added.

See Using tools in Python for more info on how you can avoid having to append the toolbox alias.  I'm not positive about this, but if the name of the tool is unique (not found in any other system toolbox), you may not have to append the _<alias>.  But the best practice is to always identify the toolbox, using _<alias> or other methods mentioned in  Using tools in Python
0 Kudos