Reputation: 274
I've done this in one of my programs, it works as intended but I would like to know if using try as a condition in this way this way could cause problems (the exception is raised around a third of the time)
try:
# This line create a condition by raising or not the error
next(external_data.cursor.execute(statement))
return 'C'
except StopIteration:
return 'F'
Upvotes: 0
Views: 43
Reputation: 969
In general, no. AFAIK Python even uses exceptions internally to break loops. The only thing that could happen is, that you catch exceptions, that actually should have been raised.
Upvotes: 1