I am teaching myslef Python from a GIS tutorial 'Writing_Geoprocessing_Scripts.pdf'. 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 + "/" + GP.ValidateTableName(fc,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. Thanks, Kevin
#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[1] is the name of the script GP.workspace = sys.argv[1] #Set the clip featureclass clipFeatures = sys.argv[2] #Set the output workspace outWorkspace = sys.argv[3] #Set the cluster tolerance clusterTolerance = sys.argv[4] #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 try: #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 fcs.Reset() fc = fcs.Next() while fc: #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, outWorkspace) #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)[1]): GP.Clip(fc, clipFeatures, outFeatureClass, clusterTolerance) fc = fcs.Next() except: #except statement is required by the earlier try statement #if an error occurs during execution the code in the except #block will run GP.AddMessage(GP.GetMessages(2)) print GP.GetMessages(2)
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor