As Jayanth Koushik pointed out removing items from a list while iterating over it causes this error.
Python continue after Exception [closed]
-
14-10-2022 - |
Question
i know this question has been asked already, but i doesn't get a solution yet. I assume that this exception should continue the for loop, but it doesn't. Have spent some time trying to resolve this issue but i cant find any good solution. Got any idea?
for store in CREATE:
#print "Create ticket:"
print '-' * 80
print store.storeNumber, store.date
br.open(OPEN_NEW_CASE_URL)
form = br.select_form("selsite01")
try:
#assert store.internalID
br["site_id"] = [store.internalID]
except AttributeError:
CREATE.remove(store) # if store is not found on the m***** drop down field
print "[WARNING] Store", store.storeNumber ,"not found in the ticket list, could not create."
continue
br.submit()
""" Build ticket from config file """
br.select_form("newcase")
[.... more code ....]
br.open(LOGOUT_URL) # be nice and logout
edit (solved the issue):
try:
#assert store.internalID
br["site_id"] = [store.internalID]
except AttributeError:
print "[WARNING] Store", store.storeNumber ,"not found in the ticket list, could not create."
continue
br.submit()
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow