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

Why would you import like this?

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

Code:

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?

Code:

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:

Code:

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

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

Code:

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


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

Viewing all articles
Browse latest Browse all 2485

Trending Articles