Repeat an exception
jeanmichel at sequans.com
Thu Feb 4 13:59:52 CET 2010
> In other words:
> for attempt in range(2):
> spanish_field = translate(english_field, lang_to='es',
> except TranslationError:
> # Didn't break out of the loop, therefore not successful.
> print "Translation failed"
What the hell is this 'for else' loop !! :D First time I see this
statement for years.
I'd never thought I'd still learn something that basic.
My first impression is that the mechansim is not that obvious. MRAB's
need for a comment tends to confirm this.
I'll try to remember that anyway. Nice addition.
More information about the Python-list