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?

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.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.