rdharles

Why would you import like this?

Discussion created by rdharles on Sep 24, 2013
Latest reply on Sep 25, 2013 by mdenil
When putting a tool in a python script, I've always added a tool by putting the name of the tool, followed by an underscore and then the toolbox name like this:

import arcpy
arcpy.SimplifyLine_cartography(mergedFeatures, simplifiedFeatures, "BEND_SIMPLIFY", 100, "RESOLVE_ERRORS", "KEEP_COLLAPSED_POINTS", "CHECK")


A co-worker found the following in the ArcGIS help file.  What, if any, is the advantage of doing it this way?

import arcpy.cartography as CA
CA.SimplifyLine(mergedFeatures, simplifiedFeatures, "BEND_SIMPLIFY", 100, "RESOLVE_ERRORS", "KEEP_COLLAPSED_POINTS", "CHECK")


I don't see the point?

Also, I see this quite a bit:

import arcpy
from arcpy import env
env.workspace = "C:/temp"


...isn't it easier to just to this:

import arcpy
arcpy.env.workspace = "C:/temp"



Maybe there's a legit reason to write extra code?

Outcomes