All,
I am still new to using python and coding in general. I have a very basic question regarding tool signatures. When I look up a tool...say Copy Features I am provided with this :
arcpy.management.CopyFeatures(in_features, out_feature_class, {config_keyword}, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})
However the examples and the documentation on understanding tool syntax show the tool signature should be arcpy.CopyFeatures_management
I have just noticed this and have been using arcpy.management.CopyFeatures in my code without any noticeable issues.
Does it matter? Does anyone know why they provide arcpy.toolboxalias.tool when all examples and documents show arcy.tool_toolboxalias ? Should I go back and change my code?
Thank you to anyone who can help me on my path towards automation!
Solved! Go to Solution.
No don't go back and change your code, both ways are acceptable.
The arcpy.management.CopyFeatures() approach is as I have understood it is the modern more industry standard approach, you drill down into the module where the function is. In my mind it matches the coding styles of VB and c# .net.
The older style (which is what I use and "grown up on") arcpy.CopyFeatures_management() is ubiquitous throughout the Help file simply because ESRI have not chosen to standardise their code samples which I guess is leading to confusion and questions being asked by users such as yourself.
I don't believe there is any loss in performance if you use one style over another. The important message I can leave here is stick to one style when coding and add as many comments as you can to make your code readable to you and others.
No don't go back and change your code, both ways are acceptable.
The arcpy.management.CopyFeatures() approach is as I have understood it is the modern more industry standard approach, you drill down into the module where the function is. In my mind it matches the coding styles of VB and c# .net.
The older style (which is what I use and "grown up on") arcpy.CopyFeatures_management() is ubiquitous throughout the Help file simply because ESRI have not chosen to standardise their code samples which I guess is leading to confusion and questions being asked by users such as yourself.
I don't believe there is any loss in performance if you use one style over another. The important message I can leave here is stick to one style when coding and add as many comments as you can to make your code readable to you and others.
Awesome. Thanks for helping to clear that up and for the additional advice!
@DuncanHornby wrote:The important message I can leave here is stick to one style when coding and add as many comments as you can to make your code readable to you and others.
I agree. Consistency is very important. Even if your code pattern is old/inefficient/dense and you don't realize until half way through, either fix it the same way everywhere or continue the pattern.
...simply because ESRI have not chosen to standardise their code samples...
Ummm... errr... ahh... maybe it's time to do so?