[Tutor] Checking Syntax
kevinfpearson at gmail.com
Thu Jun 18 21:55:15 CEST 2009
I am teaching myslef Python from a GIS tutorial
I have typed everything exactly like it is in the tutorial and when I go to
run a check on the sytax (before I try running the program) it places a
cursor like so:
outFeatureClas|s = outWorkspace + "/" +
I have checked the tutorial and I can't see what is wrong. I can't get past
this until it is corrected.
I have attached the script.
Any advice would be greatly appreciated.
#Import standard library modules
#imports system, operating system & Windows 32 modules
#sys refers to Python system, os refers to acess to operating system
import win32com.client, sys, os
#Create the Geoprocessor object
GP = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
#Set the input workspace
#argv = argument value
#argv is the name of the script
GP.workspace = sys.argv
#Set the clip featureclass
clipFeatures = sys.argv
#Set the output workspace
outWorkspace = sys.argv
#Set the cluster tolerance
clusterTolerance = sys.argv
#try statement defines the beginning of a block of code that will be
#handled by its associated exception handler, or except statement
#try/except statements are used to handle unexpected errors
#this defines that the program should do when an exception happens
#Get a list of the featureclasses in the input folder
fcs = GP.ListFeatureClasses()
#Loop through the list of feature classes
#always reset a list so the first item is extracted
#so you can be sure you get the first item in the list
fc = fcs.Next()
#Validate the new feature class name for the output workspace.
#ValidateTableName ensures output name is valid for output
#workspace, it returns unique name so no existing data is overwritten.
outFeatureClass = outWorkspace + "/" + GP.ValidateTableName(fc,
#Clip each feature class in list with the clip feature class.
#Do not clip the clipFeatures, it may be in the same workspace.
if str(fc) != str(os.path.split(clipFeatures)):
GP.Clip(fc, clipFeatures, outFeatureClass,
fc = fcs.Next()
#except statement is required by the earlier try statement
#if an error occurs during execution the code in the except
#block will run
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor