Greetings,
I want to search all Features, but exclude those that are a 'NoneType' object
I tried to exclude the 'NoneType' object in the search, this is not working??
Appreciate any pointers, to skip the 'NoneType'
serviceItems = portal.content.search("*", item_type="Feature*", max_items=4000)
for item in serviceItems:
if item != 'NoneType':
layers = item.layers
#print(layers)
#try:
for lyr in item.layers:
print(item.id, item.url, lyr.properties["id"], lyr.properties["name"], item.tags )
rowitem = (item.id, item.url, lyr.properties["id"], lyr.properties["name"], item.tags)
filewriter.writerow(rowitem )
else:
print("EROR")
Solved! Go to Solution.
if item is not None:
blah blah
# or
if item:
blah blah
the type is None, you don't test for Nonetype
if item is not None:
blah blah
# or
if item:
blah blah
the type is None, you don't test for Nonetype