[Tutor] Checking Syntax

Kevin Pearson 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[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
    #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()
    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,
    #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,
    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
    print GP.GetMessages(2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090618/0434d174/attachment.htm>

More information about the Tutor mailing list