__init__ method and raising exceptions
Vikram
vvikram at stanford.edu
Fri Apr 1 02:47:27 EST 2005
> I can't use 'break' or 'continue' in a class method, nor can I return a
> boolean value from __init__() to check for errors within the for-loop.
> How would I be able to stop the current iteration and continue with the
> next after reporting an error?
maybe i don't fully understand your qn but why don't you let __init__ of
your class raise an exception and then catch it in the outer for loop and
continue. something like:
for i in ...
try:
foo()
except:
continue
Vikram
More information about the Python-list
mailing list