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
1 Answer 1
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")])
Explore related questions
See similar questions with these tags.