6

I'm working on a Python script that is heavily utilizing Network Analyst tools. I understand that dot notation is used to call methods from a class, but don't really get why/how ArcPy functions appear to be callable with different syntaxes. Example:

 import arcpy
 from arcpy import na
 # what is the difference between this:
 arcpy.na.CopyTraversedSourceFeatures(routeLyr, gdb, edges, junctions, turns)
 #and this:
 arcpy.CopyTraversedSourceFeatures_na(routeLyr, gdb, edges, junctions, turns)

Both syntaxes appear to behave the same when running from the Python window in an ArcMap session, but will these behave differently when running from a different environment, such as a script tool or a batch file run in Task Scheduler?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Dec 1, 2017 at 16:52
0

1 Answer 1

10

Both are just different names for the same thing. You can see this by using the is operator:

arcpy.na.CopyTraversedSourceFeatures is arcpy.CopyTraversedSourceFeatures_na

will return:

True

Which tells you that both of these names point to the same object.

Your best course of action is to pick one way of doing it in your scripts and stick with it. Just be consistent.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Dec 1, 2017 at 18:12
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.