Describe vs Format functions

المشرف العام

Administrator
طاقم الإدارة
Below is a code using the Describe function, and one using the Format function in the same way (neither prints correctly, but that is for another Question). Reading the ESRI Help files on Describe, I believe this is the technique I should use. However, it has been suggested that I should use the Format function instead.

What is the functional/fundamental difference between these functions? Why would I want to chose one over the other? What am I actually saying with the syntax of the Format function? I somewhat understand the Describe function, so why would using the Format function be better?

the codes:Describe:

import arcpy, os, sys from arcpy import env arcpy.env.overwriteOutput = True #gdb = raw_input(r"Please insert the full pathname of the Input Geodatabase :") gdb = r"F:\........\&&&&&.gdb" print ("Geodatabase: " +gdb) env.workspace = gdb env.scratchworkspace = gdb fc_list = arcpy.ListFeatureClasses() fc_count = len(fc_list) if fc_count == True: #if fc_count >= 1: print ("\nFeatureClasses:") for fc in fc_list: print ("\t" + fc) fclass = gdb + "\\" + fc fld_list = arcpy.ListFields(fclass) for fld in fld_list: name = arcpy.Describe(fld).name kind = arcpy.Describe(fld).type #name = "x" #kind = "y" print ("\t\t" + name + ("(" + kind + ")"))Format:

import arcpy, os, sys from arcpy import env arcpy.env.overwriteOutput = True #gdb = raw_input(r"Please insert the full pathname of the Input Geodatabase :") gdb = r"F:\........\&&&&&.gdb" env.workspace = gdb env.scratchworkspace = gdb fc_list = arcpy.ListFeatureClasses() fc_count = len(fc_list) if fc_count == True: #if fc_count >= 1: print ("\nFeatureClasses:") for fc in fc_list: print ("\t" + fc) fclass = gdb + "\\" + fc fld_list = arcpy.ListFields(fclass) for fld in fld_list: print(" \t \t {0} ({1})".format(field.name, field.type))

أكثر...
 
أعلى