fertseller.blogg.se

Professional notebooks
Professional notebooks








professional notebooks

The code, without comments, is only a few lines.

professional notebooks

#Professional notebooks code

The code block then prints the feature class name (the contents of the fc variable) and the count (the contents of the count variable). The code block creates a variable named count and sets it equal to the result of calling GetCount on the current item from the list. In this case, the inputs are the names in the list, and the variable fc is set to each one of them, in turn, and the code in the indented block runs on it. For loops take a set of inputs and a block of indented code and run the code block on each of the inputs. The next part of the code uses a for loop. If something goes wrong, it is helpful to know what is in that variable. Printing the list isn't necessary, but it is a good way to ensure that you have the results that you expect in the variable. This time the list contains strings with the names of the feature classes. This code makes a new variable named fc_list and sets it equal to the result of running arcpy.ListFeatureClasses on the current workspace, Toronto.gdb. You used a list and list indexing earlier. The lines that are comments don't run they are there to help you understand what the code does. Comments are text that appears after the # signs. This code includes comments to explain what each step does.

professional notebooks

# Print out the name of the feature class and the count # Set the variable count equal to the result of Get Count # Run Get Count on the current fc from the list # equal to each feature class name in the list # use a loop to set the variable fc to be # works on the current workspace or a path # List the feature classes in a workspace










Professional notebooks