0

I am trying to figure out why my ArcGIS Pro Python Script Tool with validation fails to open when I insert the block of code in my image.

def initializeParameters(self):
    shpFile = r"C:\LPA\Data\ne_10m_admin_0_countries.shp"
    self.params[0].filter.list = sorted([row[0] for row in
arcpy.da.SearchCursor(shpFile, "NAME")])
      return

enter image description here

0

1 Answer 1

2

I think that it is the two extra spaces of indentation before your first return that is causing the problem.

Try this instead of the code that you have presented:

def initializeParameters(self):
    shpFile = r"C:\LPA\Data\ne_10m_admin_0_countries.shp"
    self.params[0].filter.list = sorted([row[0] for row in arcpy.da.SearchCursor(shpFile, "NAME")])
    return

In a comment you showed a misspelt line of code that was giving a different error:

self.params[0].filter.list = sorted( [row[0] for row in arcpy.da.SearchCursur(shpFile, "NAME")])

should have SearchCursor (not SearchCursur):

self.params[0].filter.list = sorted( [row[0] for row in arcpy.da.SearchCursur(shpFile, "NAME")])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.