How to catch a python exception in a list comprehension?
I have a list comprehension in Python in which an iteration can throw an exception.
For instance, if I have:
foo = (5,7,1,0,9)
[1/i for i in foo]
I'll get an exception while iterating over element ‘0’ of the tuple.
How can I handle this exception and continue execution of the list comprehension?